Re: Need help: about OOP inheritance/abstract class
From: Elementary Penguin (singing_at_hare.krishna)
Date: 01/28/05
- Next message: Kevin Spencer: "Re: Sending a path to a FILE control ( it has to be possible! )"
- Previous message: Patrice: "Re: Sending a path to a FILE control ( it has to be possible! )"
- In reply to: Tee: "Re: Need help: about OOP inheritance/abstract class"
- Next in thread: Olorin: "Re: Need help: about OOP inheritance/abstract class"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 28 Jan 2005 16:56:11 GMT
Tee wrote:
>> Have you ever used the /interface/ keyword though?
> Yes, I know what is it and used it before. Since I can't force a class to
> implements an interface, I don't think this is what I am looking for.
>
>> No, but you can create a class that instantiates the user control in the
>> constructor, or that inherits it, and inherit the interfaces.
> Sorry I am somehow a bit lost in this, I can't figure it out. Can you tell
> me how to instantiates user control in constructor?
I used this trick when I was trying to get an XmlDocument to load at runtime
(static), by instantiating it. Normally, I had to run the .Load method --
but I can't run a method when I declare, I have to declare, then .Load.
So, I created a new class with a constructor that did the load.
In my calling class
CustomXmlDocClass myXml = new CustomXmlDocClass()
Then in the constructor of the instantiated class:
CustomXmlDocClass
{
public XmlDocument xd;
CustomXmlDocCalss()
//the constructor
{
XmlDocument _xd = new XmlDocument();
_xd.Load("whatever.xml");
xd = _xd;
}
}
Now myXml is loaded with whatever.xml at run time.
> I think this should be what I need, greatly appreciate if you could
> elaborate on this.
>
>
> Thanks,
> Tee
>
>
>
> "Elementary Penguin" <singing@hare.krishna> wrote in message
> news:uP%Jd.6676$YD5.1145@newsread3.news.pas.earthlink.net...
>> Tee wrote:
>>
>>
>> > Is stub method a keyword?
>>
>> Sorry, bad choice of words.
>>
>> Have you ever used the /interface/ keyword though?
>>
>> You define methods, but just in terms of the input parameters.
>>
>> Then, its up to the inheriting classes to implement. Similar to, but
>> not exactly, to an abstract class.
>>
>> And there's no *default* implementation.
>>
>>
>> > What I am doing is a usercontrol, what I meant "I can't open the
>> > usercontrol in VS designer" is because when it opens up the
>> > form/usercontrol, it actually called it as "new", and abstract class
> can't
>> > be declared as new"
>>
>> No, but you can create a class that instantiates the user control in the
>> constructor, or that inherits it, and inherit the interfaces.
>>
>>
>>
>> >
>> > Thanks.
>> >
>> >
>> > "Elementary Penguin" <singing@hare.krishna> wrote in message
>> > news:RZYJd.6531$YD5.6364@newsread3.news.pas.earthlink.net...
>> >> Tee wrote:
>> >>
>> >> > Hi,
>> >> >
>> >> > I have a base usercontrol with a method (blank method, no code), I
> have
>> >> > another few usercontrols that will inherit this base usercontrol,
>> >> > but
> I
>> >> > want to force all the usercontrol that inheriting this base
> usercontrol
>> > to
>> >> > override the method with its own code. How do I do it?
>> >>
>> >> If you are going to /force/ them to override it ( polymorphism ) why
> have
>> > it
>> >> in the first place?
>> >>
>> >> You should define an *interface* with a stub method and force them to
>> >> implement it.
>> >>
>> >> I do this in one of my web service applications. There are two
>> >> interfaces
>> >> and a base abstract class. The interface accounts for methods that
> must
>> >> be implemented in the derived classes, but which have no default
>> >> method in
>> >> the abstract class. So each derived class has one abstract class and
>> >> two interfaces to inherit from.
>> >>
>> >>
>> >> --
>> >> http://texeme.com
>> >> Textcasting Technology
>> >> Incognito Blog
>> >> http://incognito.texeme.com
>> >>
>>
>> --
>> http://texeme.com
>> Textcasting Technology
>> Incognito Blog
>> http://incognito.texeme.com
>>
-- Texeme http://texeme.com
- Next message: Kevin Spencer: "Re: Sending a path to a FILE control ( it has to be possible! )"
- Previous message: Patrice: "Re: Sending a path to a FILE control ( it has to be possible! )"
- In reply to: Tee: "Re: Need help: about OOP inheritance/abstract class"
- Next in thread: Olorin: "Re: Need help: about OOP inheritance/abstract class"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|