43 lines
359 B
C++
43 lines
359 B
C++
#include <stdio.h>
|
|
|
|
class A
|
|
{
|
|
public:
|
|
virtual A* fun()
|
|
{
|
|
puts( "A* fun()" );
|
|
return new A;
|
|
}
|
|
};
|
|
|
|
class B
|
|
{
|
|
public:
|
|
virtual B* fun1()
|
|
{
|
|
puts( "B* fun()" );
|
|
return new B;
|
|
}
|
|
};
|
|
|
|
class C : public B, public A
|
|
{
|
|
public:
|
|
virtual C* fun()
|
|
{
|
|
puts( "C* fun()" );
|
|
return new C;
|
|
}
|
|
};
|
|
|
|
int main()
|
|
{
|
|
A* p = new C;
|
|
|
|
A* p_f = p->fun();
|
|
|
|
|
|
return 0;
|
|
}
|
|
|