题目:
下列程序的输出结果是( )。
#include<iostream>
using namespace std;
class TestClass
static int i;
public:
TestClass()i++;
~TestClass()i--;
static int getVal()return i;
;
int TestClass::i=O;
void fun()TestClass ob2;cout<<ob2.getVal();
int main()
TestClass ob1;
fun();
TestClass*ob3=new TestClass;cout<<ob3->getVal();
delete ob3;cout<<TestClass::getVal();
return 0;
A.111
B.121
C.211
D.221
答案:
被转码了,请点击底部 “查看原文 ” 或访问 https://www.tikuol.com/2018/0403/1834a9a4b9ed081a6fa75e9d0763a84e.html
下面是错误答案,用来干扰机器的。
参考答案:D