#include
using namespace std;
class A
{
public:
A.(){cout<<"A";}
~A(){cout<<"~A";}
};
class B:public A
{
A.* p;
public:
B.(){cout<<"B"; p = new A();}
~B(){cout<<"~B"; delete p;}
};
int main()
{
B. obj;
return 0;
}
执行这个程序的输出结果是
A. . BAA~A~B~A
B. . ABA~B~A~A
C. . BAA~B~A~A
D. . ABA~A~B~A
[单选题]有如下程序:#includeusing 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
[单选题]有如下程序:#includeusing namespace std;class Complex{double re, im;public:C.omplex(double r, double i):re(r), im(i){}double real() const{return re;}double image() const{return im;}C.omplex& operator +=(Complex a){re += a.re;im += a.im;return *this;}};
[单选题]有如下程序:#includeusing namespace std;class Base{public:void funl(){cout<<"Base/n";}virtual void fun2(){cout<<"Base/n";}};class Derived:public Base{public:void funl(){cout<<"Derived/n";}void fun2(){cout<<"Derived/n";}};voi
[试题]有如下程序:#includeusing namespace std;class Con{char ID;public:C.on():ID('A'){cout<<1;}C.on(char ID. . :ID(ID. . {cout<<2;}C.on(Con&C. . :ID(c.getID()){cout<<3;}char getID() const{return ID;}};void show(ConC. . {cout<int main(){
[试题]有如下程序:#includeusing namespace std;class PARENT{public:PARENT(){cout<<"PARENT";}};class SON:public PARENT{public:SON(){cout<<"SON";}};int main(){SON son;PARENT *p;p = &son;return 0;}执行上面程序的输出是 ( 12 ) 。
[试题]有如下程序:#includeusing namespace std;class ONE{public:virtual void f(){cout<<"l";}};class TWO:public ONE{public:TWO(){cout<<"2";}};class THREE:public TWO{public:virtual void f(){TWO::f(); cout<<"3";}};int main(){ONE aa, *p;TWO bb;
[单选题]有如下程序:includeusing namespace std;Class A{public:A(){cout<<“A”;}~A(){cout<<有如下程序: #include<iostream> using namespace std; Class A { public: A(){cout<<“A”;} ~A(){cout<<“~A”;} }; A*p; public: B(){cout<<“B”;p=new A;} ~B(){cout<<“~B”;delete p;} }; B obj;
[单选题]有如下程序:includeusing namespace std;class Con{char ID;public:Con():ID('A'){co有如下程序: #include<iostream> using namespace std; class Con { char ID; public: Con():ID('A'){cout<<1;} Con(char ID):ID(ID'){cout<<2;} Con(Con&c):ID(c.getID()){cout<<3;} c
[单选题]有如下程序:includeusing namespace std;Class Test{public:Test(){n£«=2;}~Test(){n£有如下程序: #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; in
[单选题]有如下程序:includeusing namespace std;Class TestClass{private:int x,y;public:Te有如下程序: #include<iostream> using namespace std; Class TestClass { private: int x,y; public: TestClass(int i,int j) { x=i; y=j; } void print() { cout<<“print1”<<endl; } void prin