填空题
有如下类定义:
class Sample
public:
Sample( );
~Sample( );
private:
Static int date:
;
将静态数据成员data初始化为0的语句是______。
【参考答案】
int Sample::data=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( )<<endl; delete gs; return 0; 程序的输出结果是______。
点击查看答案&解析
填空题
如下程序定义了“单词”类word,类中重载了<运算符,用于比较“单词”的大小,返回相应的逻辑值。程序的输出结果为:After Sorting:Happy Welcome,请将程序补充完整。 #include<iostream> #include<string> using namespace std; class Word public: Word(strings):str(s) string getStr( )return str; ______constreturn(str<w.str); friend ostream& operator<<(ostream& output,const Word &w)output<<w.str;return output; private: string str; ; int main( ) Word wl( Happy ),w2( Welcome ); cout<< After sorting: ; if(wl<w2)cout<<w1<< <<w2; else cout<<w2<<’’<<w1: return 0;
点击查看答案&解析
相关试题
数据库管理系统是
下列关于模板形参的描述中,错误的是
在下列枚举类型的定义中,包含枚举值3的是
下列关于运算符函数的叙述中,错误的是
有以下类定义: class A char*a; pub...