#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;
}
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;
}