#include
using namespace std;
class Father;
Father * p;
class Father
{
public:
Father()
{
p = this;
}
void output()
{
cout << "this指向基类" << endl;
}
};
class Son : public Father
{
public:
void output()
{
cout << "this指向派生类" << endl;
}
};
void main()
{
p->output();
system("pause");
}
准确说是指向基类和派生类实例化的对象,严谨一些。