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

smile2u (smile2u)
#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;
}
(#346973@0)
2002-1-25 -05:00

回到话题: 问一个C++的问题

回到论坛: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论

URL:   
http://www.rolia.net/zh/post.php?f=0&p=346973