单项选择题

下列类的定义中,有( )处语法错误。 class Base { public: Base ( ) { } Base(int i) { data=i; } private: int data; }; class Derive : public Base { public: Derive() : Base(O){} Derive (int x) { d=x; } void setvalue(int i) { data=i; } private: d; };

A.1
B.2
C.3
D.4
<上一题 目录 下一题>
热门 试题

单项选择题
有如下类的定义。空格处的语句是( )。 class MyClass { ____________ int x, y; public: MyClass(int a=0,int b=0) { x=a; y=b; } static void change() { x-=10; y-=10; } };
A.static
B.const
C.private
D.不需要填入内容
单项选择题
若有以下程序: #include <iostream> using namespace std; class Base { int x; protected: int y; public: int z; void setx(int i) { x=i; } int getx ( ) { return x; } }; class Inherit : private Base { private: int m; public: int p; void setvalue(int a,int b,int c, int d) { setx(a) ; y=b; z=c; m=d; } void display() { cout<<getx ()<< , <<y<< , <<z<< , <<m<<end1; } }; int main() { Inherit A; A.setvalue(1,2,3,4); A.display(); return 0; } 程序运行后的输出结果是( )。
A.1,2,3,4
B.产生语法错误
C.4,3,2,1
D.2,3,4,5
相关试题
  • 下列函数中,哪项是正确的递归函数( )。...