下列程序的执行结果是()。# include < iostream >using namespace std;class Test {public:Test(){ n+=2; }~Test() { n-=3;}static int getNum() { return n;}private:static int n;};int Test::n = 1;int main(){Test* P = new Test;delete p;cout<< "n=" < Test::getNum() << endl;return O;}
A. n=0
B. n=1
C. n=2
D. n=3
查看答案
下列程序执行后的输出结果是( )。#include using namespace std;class AA{int n;public:AA(int k):n(k){}int get(){return n;}int get()const{ return n+ 1;}};int main( ){AA a(5);const AA b(6);cout<
A. 55
B. 57
C. 75
D. 77
有以下类定义:class AA{int a;public:int getRef( )const{return &a;} // ①int getValue( )const{return a;} //②void set( int n)const{a=n;} //③friend void show(AA aa)const{cout<
A. ①
B. ②
C. ③
D. ④
有以下类定义:class Point{int x_,y_;Public:Point (): x_(0), y_(0){}Point ( int x, int y =0);x_(x), y _(y){}};若执行语句:Point a(2), b[3],* c[4];则 Point 类的构造函数被调用的次数是( )
A. 2次
B. 3次
C. 4次
D. 5次
有以下类定义: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. ④