|
-
April 10th, 2002, 03:38 AM
#1
Please help me with this simple program.
#include <iostream>
using namespace std;
class CFather{
public:
CFather() { InitInstance(); }
virtual void InitInstance(){
cout << "I am the father." << endl;
}
};
class CSon : public CFather{
public:
void InitInstance(){
cout << "I am the son." << endl;
}
};
int main()
{
CSon son;
return 0;
}
The program's output is:
I am the father.
How can I make the CFather's constructor invoke the InitInstance function defined in the CSon?
Thanks a lot!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|