其他分享
首页 > 其他分享> > 25

25

作者:互联网

 1 #include <iostream>
 2 using namespace std;
 3 class A {
 4     private:
 5     int nVal;
 6     public:
 7     void Fun()
 8     { cout << "A::Fun" << endl; };
 9     virtual void Do()
10     { cout << "A::Do" << endl; }
11 };
12 class B:public A {
13     public:
14     virtual void Do()
15     { cout << "B::Do" << endl;}
16 };
17 class C:public B {
18     public:
19     void Do( )
20     { cout <<"C::Do"<<endl; }
21     void Fun()
22     { cout << "C::Fun" << endl; }
23 };
24 void Call(
25 A* p
26 ) {
27     p->Fun(); p->Do();
28 }
29 int main() {
30     Call( new A());
31     Call( new C());
32     return 0;
33 }

 

标签:25,cout,int,namespace,Call,Fun,new
来源: https://www.cnblogs.com/balabalabubalabala/p/16691284.html