See whether this implement what you want:

clinux (C/Linux)
derived.cpp
#include "Base.h"
class Derived : public Base
{
public:
void did(){cout << "this is derived class" << endl;
cout << "tt = " << getTT() << endl;}
private:
};

base.cpp
#include <iostream.h>
class Base
{
public:
int getTT() { return tt;}
virtual void did(){};
private:
int tt;
};

int main()
{
Base *b = new Derived;
b->did();
return 0;
}
(#346386@0)
2002-1-24 -05:00

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

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

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