mirror of
https://github.com/Light-City/CPlusPlusThings.git
synced 2026-02-03 10:33:25 +08:00
22 lines
305 B
C++
22 lines
305 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;
|
|
}
|