上一页 1 ··· 28 29 30 31 32 33 34 35 36 ··· 54 下一页
摘要: 在构造函数和析构函数中调用虚函数 源程序: #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)
摘要: 源程序: // // main.cpp // virtualfunction // // Created by duanqibo on 2020/1/9. // Copyright © 2020年 duanqibo. All rights reserved. // #include <iostrea 阅读全文
posted @ 2020-01-09 23:00 bobo哥 阅读(160) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream> using namespace std; static int glos = 100; void f() { int a = 1; static int fs = 1; cout << "在f中:a(自动)=" << a << " fs(静态)=" 阅读全文
posted @ 2019-12-23 08:41 bobo哥 阅读(149) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream> using namespace std; class samp { public: void setij(int a, int b) { i = a; j = b; } ~samp() { cout << "析构..." << endl; } int 阅读全文
posted @ 2019-12-23 08:36 bobo哥 阅读(221) 评论(0) 推荐(0)
摘要: 源程序: #include <iostream> using namespace std; class A { private: int a, b; public: A(int k = 4, int j = 0) { a = k; b = j; } ~A(); void show(); }; voi 阅读全文
posted @ 2019-12-23 08:32 bobo哥 阅读(119) 评论(0) 推荐(0)
上一页 1 ··· 28 29 30 31 32 33 34 35 36 ··· 54 下一页