📄 compclass.h
字号:
// CompClass.h
#ifndef COMPCLASS_H
#define COMPCLASS_H
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
using std::cerr;
//---- 宣告类别 Component --------
class Component
{
private:
int I;
public:
// 类别 Component 的建构函数
Component (): I(1) {} // 预设建构函数
Component (int N): I(N) {} // 建构函数
// 类别 Component 的解构函数
~Component() {}
int Get() const {return I;}
void Double() {I*=2;}
};
//---- 宣告类别 Host --------
class Host
{
private:
int k;
Component C1, C2;
public:
Component C3;
// 类别 Host 的建构函数
Host() : k(1), C1(1), C2(1), C3(1) {}
Host(int L, int M, int N, int P)
: k(L), C1(M), C2(N), C3(P) {}
// 类别 Host 的解构函数
~Host() {}
int Get() const {return k;}
void Double() {k*=2;}
void DoubleComp()
{C1.Double(); C2.Double(); C3.Double();}
int GetC1() {return C1.Get();}
int GetC2() {return C2.Get();}
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -