[Dev-C++] accessing derived class methods
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Dane E. <dg...@wo...> - 2005-09-20 04:17:22
|
Neeraj, Thanks for the input. I was afraid of that. I suppose this holds true always. I was hoping that a nested class with some friend declarations might provide a solution but I accept defeat. Thanks for clearing things up. Dane Begin forwarded message: > Dane, > > Ideally what you are doing should work the only care which must be > taken is that the base class pointers must point to correct derived > class objects and second is that you can't access any function in > derived class which is not defined as virtual in base class. > I mean if getSpecificData() is not defined as virtual in base you can > not a derived version of call it using base class pointer. > > Regards > Neeraj > > -----Original Message----- > From: dev...@li... > [mailto:dev...@li...] On Behalf Of Dane > Ensign > Sent: Tuesday, September 20, 2005 8:09 AM > To: dev...@li... > Subject: [Dev-C++] accessing derived class methods > > Hi all, > > I have a simple base class and a few derived classes from it. My goal > is to build an array of pointers where I can assign derived class > objects into, then access the different derived class attributes > as needed. > > So I have an employee class. I derive a laborer, scientist, and > manager class from it. I build some basic virtual functions in the > employee class, and each derived class > has a couple of specific attributes that I want to call, like > getSpecificData(). > > I made an array of base class pointers then tried accessing the > derived class methods, but it doesnt work. I made an array of void* > pointers and tried to access derived class methods and that doesnt > work. > > I realize that I could build a pure virtual function in the base > class that would only be used to access derived class atrributes, but > that is silly. Please can someone point* me in the right direction? > > Thanks for any help you can offer. > > Best regards, > > Dane > da...@de... > > > > > ------------------------------------------------------- > SF.Net email is sponsored by: > Tame your development challenges with Apache's Geronimo App Server. > Download > it for free - -and be entered to win a 42" plasma tv or your very own > Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > > Dane da...@de... |