Move all C++ tests to cpp.
This commit is contained in:
42
cpp/virtual_overriding.cpp
Normal file
42
cpp/virtual_overriding.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user