对下面程序描述正确的是( )。 #include < iostream > using namespace std; class A { private: int i; public: class B { private: int j; protected: int k; int fun1 ( ); } MyB; int fun2 ( ); }
A.定义类B的对象的语句是: A::B b;
B.类A的成员函数fun2()可以用MyB.j的方式访问类B的私有成员j。
C.类A的成员函数fun2()可以用MyB.k的方式访问类B的保护成员k。
D.类B的成员函数fun1()可以直接访问类A的私有成员i。
第1题:
有以下程序: #include <iostream> using namespace std; #define PI 3.14 class Point { private: int x,y; public: Point(int a,int b) { x=a; y=b; } int getx() { return x; }
A.314
B.157
C.78.5
D.153.86
第2题:
下面程序错误的语句是
①#include<iostream.h>
②void main()
③{
④ int * p=new int[1]
⑤ p=9
⑥ cout<<* p<<end1;
⑦ delete []p;
⑧}
A.④
B.⑤
C.⑥
D.⑦
第3题:
第4题:
下面程序的结果是 #include<iostream.h> class test{ private: int num; public: test( ); int getint( ) {return num;} ~test( );}; test::test( ) { num=0;} test::~test( ) { cout<<"Destructor is active"<<endl;} void
A.Exiting main Destructor is active Destructor is active Destructor is active
B.Exiting main Destructor is active Destructoris active
C.Exiting main Destructoris active
D.Exiting main
第5题:
若有以下程序: #include <iost ream> using namespace std; class A { private: int a; public: A(int i) { a=i; } void disp () { cout<<a<<", "; } }; class B { private:
A.10,10,10
B.10,12,14
C.8,10,12
D.8,12,10