单项选择题
有如下类定义: class Test { public: Test(){a=0;c=0;} //① int f(int a)const {this->a=a;} //② static int g(){return a;} //③ void h(int b){Test::b=b;}; //④ private: int a; static int b; const int c; }; int Test::b=0; 在标注号码的行中,能被正确编译的是
A.①
B.②
C.③
D.④
点击查看答案&解析
<上一题
目录
下一题>
热门
试题
单项选择题
有如下程序: #include<iostream> using namespace std; class Base { private: void funl()const {cout<< funl ;} protected: void fun2() const{cout<< fun2 ;} public; void fun3() const {cout<< fun3 ;} }; class Derived:protected Base { public; void fun4() const {cout<< fun4 ;} }; int main() { Derived obj; obj.funl(); ① obj.fun2(); ② obj.fun3(); ③ obj.fun4(): ④ return 0; } 其中有语法错误的语句是
A.①②③④
B.①②③
C.②③④
D.①④
点击查看答案&解析
单项选择题
有如下类声明: class SAMPLE { int n; public: SAMPLE(int i=0):n(i) { } void setValue(int nO); }; 下列关于getValue 成员函数的实现中,正确的是
A.SAMPLE::setValue(int n{ n=nO;}
B.void SAMPLE::setValue(int n{ n=nO;}
C.void setValue(int n{ n=nO;}
D.(int n{ n=nO;}
点击查看答案&解析
相关试题
有如下类定义: class AA { int a;...
有如下程序: #include<iostream> usi...
有如下程序: #include<iostream> usi...
有如下程序: #include<iostream> usi...
有如下程序: #include<iostream> usi...