单项选择题
为完成下面的程序,应在划线处填入的语句是 #include<iostream> using namespace std; class Base { private: int x; public: Base (int i) { x=i; } ~Base(){} }; class Derived:public Base { public: ______________//完成类Derive构造函数的定义 }; int main() { Derived Obj; return 0; }
A.Derived(int :Base({}
B.Derived(){}
C.void Derived (int :Base({}
D.Derived(int {Base(;}
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
单项选择题
若有以下程序: #include<iostream> usingnamespacestd; voidsub(intx,inty,int*2) { *z=y+x; } int main() { int a,b,C; sub(8,4,&A) ; sub(6,a,&B) ; sub(a,b,&C) ; cout<<a<< , <<b<< , <<c<<end1; return 0; } 程序运行后的输出结果是
A.12,18,30
B.-12,6,8
C.6,8,10
D.12,-18,16
点击查看答案&解析
单项选择题
有以下程序: #include<iostream> using namespace std; class sample { private: int n; public: sample(){} sample(int m) { n=m; } sample add(sample s1,sample s2) { this->n=s1.n+S2.n; return(*this); } void disp() { cout<< n= <<n<<end1; } }; int main() { sample s1(10),s2(5),s3; s3.add(s1,s2); s3.disp(); retyrn 0; } 程序运行后,输出的结果是
A.n=10
B.n=5
C.n=20
D.n=15
点击查看答案&解析
相关试题
有以下程序: #include<iostrearn> us...