有如下程序:#include<iostream>using namespace std;class Toy{public:Toy(char*_n){strcp
20 查阅
有如下程序:
#include<iostream>
using namespace std;
class Toy{
public:
Toy(char*_n){strcpy(name,_n);count++;}
~Toy()}count--;}
char*GetName(){return name;}
static int getCount(){return count;}
private:
char name[10];
static int count;
};
int Toy::count=O:
int main(){
Toy tl(“Snoopy”),t2(“Mickey”),t3(“Barbie”);
cout<<t1.getCount()<<endl;
return O:
}
运行时的输出结果是
A.1
B.2
C.3
D.运行时出错
参考答案: