单项选择题

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

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

单项选择题
有如下程序: #include <iostream.h> using namespace std; class Stack public: Stack(unsigned n=10):size(n)rep_=new int [size]; top=0; Stack(Stack&s): size (s.size) rep_=new int[size]; for(int i=0;i<size;i++) rep_[i]=s.rep_[i]; top=s.top; ~Stack()delete[]rep_; void push(int
A.rep_[top]=a; top++;
int
单项选择题
有如下程序: #include<iostream> using namespace std; class TestClass public: virtual void fun1() cout<< fun1TestClass ; virtual void fun2() cout<< fun2TestClass ; ; class TestClass1:public TestClass void fun() cout<< fun1TestClass1 ; void fun2(int x) cout<< fun2TestClass1 ; ; int main() TestClass obj1,*p; TestClass1 obj2; p=&obj2; p->fun1(); p->fun2(); return 0; 该程序执行后的输出结果是( )。
A.fun1TestClass1 fun2TestClass
B.fun1TestClass1 fun2TestClass1
C.fun1TestClass fun2TestClass
D.fun1TestClass fun2TestClass1
相关试题
  • 有如下程序: #include <iostream.h>...
  • 阅读下面程序: #include<iostream.h>...
  • 有如下程序: #include<iostream> usi...