×

Loading...

Following is my answer, i put all the code in one file and use VC++6.0.

#include <iostream>
using namespace std;
class Derived;

class Base
{
public:
int getTT() { return tt;}
virtual void did(){};
void done();
protected:
int tt;
};

class Derived : public Base
{
public:
Derived(int aa=0) { tt = aa; }
void did(){cout << "this is derived class" << endl;
cout << "tt = " << getTT() << endl;}
private:
};

void Base::done()
{
tt = 8;
Base* b=new Derived (tt); // ?????????????????
b->did();
delete b;
}

int main()
{
Base b;
b.done();
return 0;
}
Report

Replies, comments and Discussions: