Inheritance
As far as I know, it should not be necessary to redeclare the methods as virtual in the derived class. Once a method has been declared virtual, it will remain virtual in all derived classes.
Nevertheless, I wrote the small code sample below in XCode to check this behavior:
Then running the following instructions properly called the derived func()...
Do you have more code to share with us?
Nevertheless, I wrote the small code sample below in XCode to check this behavior:
Code:
class Base
{
public:
virtual void func()
{
printf( "Base\n" );
}
};
class Derived : public Base
{
public:
Derived()
{
}
virtual ~Derived()
{
}
void func()
{
printf( "Derived\n" );
}
};Then running the following instructions properly called the derived func()...
Code:
Base * instance = new Derived();
instance->func();Do you have more code to share with us?
| Messages In This Thread |
|
Inheritance - merrill541 - Feb 22, 2009, 02:08 PM
Inheritance - DoG - Feb 23, 2009, 01:54 AM
Inheritance - ozirus - Feb 23, 2009 04:18 AM
Inheritance - merrill541 - Feb 23, 2009, 07:29 AM
Inheritance - ozirus - Feb 23, 2009, 07:37 AM
|
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Inheritance issues | Tekkan | 3 | 2,578 |
Jun 16, 2007 06:30 PM Last Post: Tekkan |
|

