摘要:
在构造函数和析构函数中调用虚函数 源程序: #include <iostream> using namespace std; class A{ public: virtual void hello(){ cout<<"A::hello"<<endl; } virtual void bye(){ co 阅读全文
posted @ 2020-01-12 18:01
bobo哥
阅读(126)
评论(0)
推荐(0)
摘要:
在成员函数中调用虚函数 源程序: #include <iostream> using namespace std; class CBase{ public: void func1(){ cout<<"CBase::func1()"<<endl; func2(); func3(); } virtual 阅读全文
posted @ 2020-01-12 17:53
bobo哥
阅读(407)
评论(0)
推荐(0)
摘要:
使用多态处理图形示例 源程序: #include <iostream> #include <cmath> using namespace std; class CShape { protected: double acreage; public: CShape() { //cout<<"基类构造函数 阅读全文
posted @ 2020-01-12 17:36
bobo哥
阅读(174)
评论(0)
推荐(0)
摘要:
多态机制下对象存储空间的大小 源程序: #include <iostream> using namespace std; class A { public: int i; virtual void func(); virtual void func2(); }; class B :public A 阅读全文
posted @ 2020-01-12 09:24
bobo哥
阅读(119)
评论(0)
推荐(0)
摘要:
基类引用实现多态 源程序: #include <iostream> using namespace std; class A { public: virtual void Print() { cout << "A::Print" << endl; } }; class B :public A { p 阅读全文
posted @ 2020-01-12 09:15
bobo哥
阅读(194)
评论(0)
推荐(0)
摘要:
用基类指针访问基类对象及派生类对象 源程序: #include <iostream> #include <string> using namespace std; class A { public: void put_name(string s) { name = s; } virtual void 阅读全文
posted @ 2020-01-12 09:10
bobo哥
阅读(140)
评论(0)
推荐(0)

浙公网安备 33010602011771号