![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
|||
|
|||
References to base class to access derived class only membersHi!
Can a base class reference be used to access derived class-specific members? Note that the members are not part of the base class, only part of the derived class. Thanks, Michelle |
|
#2
|
||||
|
||||
Re: References to base class to access derived class only membersIf anyone had caught my previous post, sorry. That was wrong.
The answer is : NO. Paramesh. __________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. |
|
#3
|
||||
|
||||
Re: References to base class to access derived class only membersQuote:
OOPS!!. It seems that it is possible by static_cast. My first post holds good!!! Here is how we can do it: Code:
So, consider a base class like this: CPP / C++ / C Code:
CPP / C++ / C Code:
In the main function, we can call the printderived function like this: CPP / C++ / C Code:
But doing such thing is often due to a design flaw. It is not recommended, and often leads to logical error. Regards, Paramesh. __________________
Don't walk in front of me, I may not follow. Don't walk behind me, I may not lead. Just walk beside me and be my friend. |
|
#4
|
|||
|
|||
Re: References to base class to access derived class only membersParamesh:
That makes sense! Thanks a lot for the input. I agree that this is not the best way to do things. Thanks, Michelle |
Recent GIDBlog
First week of IA training by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Fluid + class derived from Fl_Window | iga | FLTK Forum | 11 | 31-May-2005 03:02 |
| GIMcontacts - a gim fltk fluid venture | cable_guy_67 | FLTK Forum | 0 | 14-Feb-2005 14:18 |
| calling abstract base class method calls draw instead | achoo | FLTK Forum | 1 | 19-Dec-2004 09:38 |
| Error C2146: syntax error : missing ',' before identifier 'C4' | mattchew008 | CPP / C++ Forum | 2 | 19-Dec-2004 06:06 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The