有如下程序: #include using namespace std; class Monitor{ public: Monitor(char t):type(t){} void Print()const {cout

admin2010-03-15  19

问题 有如下程序:
#include
using namespace std;
class Monitor{
public:
Monitor(char t):type(t){}
void Print()const
{cout<<”The type of monito~is”<<.type《private:
char.type;
};
class Computer{
public:
Computer(int i,charC):【  】{}
void Print()const
{cout<<”The computer is”<private:
int id;
Monitot moil;
};
int main(){
const Computer myComputer(101,B);、
myComputer.Print();
return 0;
}
请将程序补充完整,使程序在运行时输出:
The computer is 101
The type of monitor is B

选项

答案mOB(c),id(i)

解析 要填写的是Computer-类的构造函数。该构造函数使用成员列表初始化。
转载请注明原文地址:https://kaotiyun.com/show/mbjp777K
0

相关试题推荐
随机试题
最新回复(0)