CPlusPlusThings/english/basic_content/virtual/set3/virtual_function1.cpp
2020-07-19 10:38:38 +08:00

23 lines
349 B
C++

#include<iostream>
using namespace std;
class Derived;
class Base {
public:
virtual void fun() { cout << "Base Fun"; }
// friend int main();
};
class Derived: public Base {
private:
void fun() { cout << "Derived Fun"; }
};
int main()
{
Base *ptr = new Derived;
ptr->fun();
return 0;
}