填空题
请将下列模板类Data补充完整。
template<typename T>
class Data
public:
void put(T v)val=v;
______get() //返回数据成员val的值,返回类型不加转换
return val;
private:
T val;
;
【参考答案】
T
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
填空题
如下程序定义了单词类word,类中重载了<运算符,用于比较单词的大小,返回相应的逻辑值。程序的输出结果为After Sorting:Happy Welcome,请将程序补充完整。 #include<iostream> #include<string> using namespaee std; class Word public: Word(string s):str(s) string getStr()return str; eonstreturn(str<w.str); friend ostream&operator<<(ostream&output,const Word &w) output<<w.str;return output; private: string str; ; int main() W0rd w1( Happy ),w2( Welcome ); cout<< After sorting: ; if(w1<w2)cout<<w1<< <<w2; else cout<<w2<< <<w1; return 0;
点击查看答案&解析
填空题
有如下程序: #include<iostream> using namespace std; class GrandChild public: GrandChild()strcpy(name, Unknown ); const char *getName()constreturn name; virtual char *getAddress()const=0; private: char name[20]; ; class GrandSon:public GrandChild public: GrandSon(char *name) char *getAddress()constreturn Shanghai ; ; int main() GrandChild *gs=new GrandSon( Feifei ); cout<<gs—>getName()<< 住在 <<gs—>getAddress()<<end1; delete gs; return 0; 运行时的输出结果是______。
点击查看答案&解析
相关试题
图形类Shape中定义了函数CalArea(),三角...