题目内容

阅读下列函数说明和C++代码,将应填入(n)处的字句写在对应栏内。
[说明]
在一些大型系统中,大多数的功能在初始化时要花费很多时间,如果在启动的时候,所有功能(包括不用的功能)都要全面初始化的话,会导致应用软件要花很多时间才能启动。因此常将程序设计成到了实际要使用某种功能的阶段才初始化该功能。
以下示例展示了Proxy(代理)模式,PrinterProxy类执行一些比较“轻”的方法,需要真正执行“重”的方法时才初始化Print类。图5-1显示了各个类间的关系。
[图5-1]
[C++代码]
class Printable{
public:
virtual void setPrinterName(string name)=0;
virtual string getprinterName()=0;
virtual void print(string name)=0;
};
class Printer:public Printable{
private:
string name;
public:
Printer(string name){
cout<<"正在产生Printer的对象实例"<<endl;
this->name=name;
}
void setPrinterName(string name){
this->name=name;
}
string getPrinterName(){
return name;
}
void print(string msg){
cout<<"======="<<name<<"==========="<<endl;
cout<<msg<<endl;
}
};
class printerproxy :public (1) {
private:
String name;
Printer *real;
public:
PrinterProxy(string name){
(2)=NULL;
this->name=name;
}
void setPrinterName(string name){
if((3))real->setPrinterName(name);
this->name=name;
}
string getPrinterName(){
return name;
}
void print(string msg){
(4);
real->print(msg);
}
void realize(){
if(real==NULL)real=(5);
}
};
(1)

查看答案
更多问题

试述薪酬体系的影响因素。

道地药材不一定是产量大、使用历史悠久的药材。()

中药的功效是主治的支撑点,主治是功效的一个范围。()

Question 4
Chan promised to pay his nephew $5,000 if his nephew would refrain from drinking liquor and using tobacco until the nephew should be 21 years of age. The nephew took Chan's words seriously, and abandoned drinking and smoking. After the nephew celebrated his 21st birthday, he asked Chan to pay the amount promised, Chan refused.
Could the nephew sue Chan for breach of the contract?

答案查题题库