64,654
社区成员
发帖
与我相关
我的任务
分享
C/C++ code
class A
{
public:
void open()
{
f();
}
private:
void f(){cout<<"A:f()"<<endl;};
};
#include <iostream>
using namespace std;
class A
{
private:
virtual void f()
{
cout<<"hello,A"<<endl;
}
};
class B:public A
{
public:
void g()
{
//f();
cout<<"hello,B"<<endl;
}
};
int main()
{
B b;//debug看,void A::f()已经被继承过来,只是不能够访问而已。
b.g();
return 0;
}
class A
{
public:
void open()
{
f();
}
private:
virtual void f()=0;
};
class B:public A
{
private:
void f()
{
cout<<"B"<<endl;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
A * a= new B;
a->open();
return 0;
}