单项选择题

有如下程序: #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; return0; } 执行后的输出结果是( )。

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

单项选择题
有如下程序: #include<iostream> using namespace std; class sample { private: int x,y; public: sample(int i,int j) { x=i; y=j; } void disp() { cout<< displ <<endl; } void disp()const { cout<< disp2 <<endl; } }; int main() { const sample a(1,2); a.disp(); return 0; } 该程序运行后的输出结果是( )。
A.disp1
B.disp2
C.disp1 disp2
D.程序编译时出错
单项选择题
若有以下程序: #include<iostream> using namespace std; class Base { public: Base() { x=0; } int x; }; class Derivedl:virtual public Base { publiC: Derivedl() { X=10; } }; Class Derived2:Virtual public Base { public: Dedved2() { x=20; } }; class Derived:public Delivedl,protected Derived2{}; int main() { Derived obj; cout<<obj.X<<endl; return 0; } 该程序运行后的输出结果是( )。
A.20
B.30
C.10
D.0
相关试题
  • 阅读下面的程序:#include<iomanip.h>v...
  • 阅读以下程序:#include<iostream.h>vo...
  • 执行以下程序后,输出“#”号的个数是 【...
  • 请定义一个函数名为A,返回值为int,没有参...
  • 以下程序的执行结果是 【12】 。#incl...