有如下程序: #include<iostream> using namespace std; class Test{ public: Test() {n+=2;} ~Test() {n-=3;}

admin2009-01-15  18

问题 有如下程序:    #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

答案1

解析
转载请注明原文地址:https://kaotiyun.com/show/zlkp777K
0

最新回复(0)