📄 b&d2.h
字号:
// B&D2.h
#include <iostream>
using namespace std;
//---- 宣告类别 Base --------
class Base
{
private:
int i;
public:
Base(): i(3)
{cout << "呼叫 Base 预设建构函数" << endl; }
Base(int N): i(N)
{cout << "呼叫 Base 建构函数" << endl; }
~Base()
{cout << "呼叫 Base 解构函数" << endl;}
void Set(int N) {i=N;}
int Get() const {return i;}
void Double() {i*=2;}
void Triple() {i*=3;}
};
//---- 宣告类别 Derived --------
class Derived : public Base
{
private:
int i;
public:
Derived(): i(5)
{cout << "呼叫 Derived 预设建构函数" << endl; }
Derived(int M, int N) : Base(M), i(N)
{cout << "呼叫 Derived 建构函数" << endl; }
~Derived()
{cout << "呼叫 Derived 解构函数" << endl;}
void Set(int N) {i=N;}
void SetBase(int N) {Base::Set(N);}
void Double() {i*=2;}
int Get() const {return i;}
int GetBase() const {return Base::Get();}
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -