[单选题]

有如下程序: include using namespace std; class Test { public

有如下程序: #include<iostream> using namespace std; class Test { public: Test(){n+=2;} ~Test(){n-=3;} static int getNum(){return n;} private: static int n; }; int Tesl::n=1 int main() { Test*p=new Test; delete p; cout<<"n="<<Tes::tgetNum()<<endl; return 0; } 执行后的输出结果是

A.n=0

B.n=1

C.n=2

D.n=3

参考答案与解析:

相关试题

有如下程序: #include using namespace std; cla

[单选题]有如下程序: include using namespace std; class Complex { dou有如下程序: #include<iostream> using namespace std; class Complex { double re, im; public: Complex(double r, double i): re(r), im(i) {} double real() const { return re; } double image() const { return

  • 查看答案
  • 有如下程序: #include using namespace std; cla

    [单选题]有如下程序: include using namespace std; class Base { public:有如下程序: #include<iostream> using namespace std; class Base { public: void fun() { cout<<"Base::fun"<<endl; } }; class Derived: public Base { public: void tim() } ____________ cout<<"Derived::

  • 查看答案
  • 有如下程序: #include using namespace std; cla

    [单选题]有如下程序: include using namespace std; class A { public: A(){cout<<"A";} ~A()有如下程序: #include<iostream> 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<

  • 查看答案
  • 有如下程序: #include using namespace std; cla

    [单选题]有如下程序: include using namespace std; class TestClass { private: int x,y; pu有如下程序: #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"<<end1; } void p

  • 查看答案
  • 有如下程序: #include using namespace std; cla

    [单选题]有如下程序: include using namespace std; class Sample{ public:有如下程序: #include<iostream> using namespace std; class Sample{ public: Sample()<) ~Sample(){cout<<'*';} }; int main(){ Sample temp[2],*pTemp[2]; return 0; } 执行这个程序输出星号(*)的个数为( )。A.1B.2C.3D.4

  • 查看答案
  • 有如下程序: #include using namespace std; cla

    [单选题]有如下程序: include using namespace std; class Demo有如下程序: #include<iostream> using namespace std; class Demo { public: Demo(){ cout<<"default constructor/n";} Demo(const Demo & x){ cout<<"copy constructor/n":} }; Demo userCode(Demo b){DemoC(b);ret

  • 查看答案
  • 有如下程序 #include using namespace std; cla

    [单选题]有如下程序 include using namespace std; class A{ public: vi有如下程序 #include <iostream> using namespace std; class A{ public: virtual void funcl( ){ cout<<"A1"; } void func2( ) { cout<<"A2"; }; class B:public A { public: void funcl( ){ cout<<"B1"; } v

  • 查看答案
  • 有如下程序 #include using namespace std; cla

    [单选题]有如下程序 include using namespace std; class Base { protected:有如下程序 #include <iostream> using namespace std; class Base { protected: Base( ){cout<<'A'; } Base(char c) { cout<<c; } }; class Derived: public Base { public: Derived(char c){ cout<<c; } };

  • 查看答案
  • 有如下程序: #include using namespace std; cla

    [单选题]有如下程序: include using namespace std; class Base{ int x; pu有如下程序: #include<iostream> using namespace std; class Base{ int x; public: Base(int n=0):x(n){cout<<n;) int getX()const{return x;} }; class Derived:public Base{ int y; public: Derived(int m,int

  • 查看答案
  • 有如下程序: #include using namespace std; cla

    [单选题]有如下程序: include using namespace std; class Amount{ int amount有如下程序: #include<iostream> using namespace std; class Amount{ int amount; public: Amount(int n=0):amount(n){} int getAmount()const{return amount;} Amount&operator9=(Amount a){ amount+=a.

  • 查看答案
  • 有如下程序: #include using namespace std; cla

    [单选题]有如下程序: include using namespace std; class BASE { public有如下程序: #include<iostream> using namespace std; class BASE { public: ~BASE(){cout<<"BASE";} }; class DERIVED:public BASE { public: ~DERIVED(){cout<<"DERIVED";} }; int main(){DERIVEDx;retum 0;}

  • 查看答案
  • 有如下程序: #include using namespace std; cla