未分类题

下列程序的执行结果是( )。 #inClude<iostream.h) #include(stdliB.h) class TestClass { public: int x,y; TestClass(){x=y=0;} TestClass(int a,int b){x=a;y=b;} void disp() { cout<<'x='<<x<<',y='<<y<<endl; } }; void main() {
A.x=2,y=2
B.x=2,y=3
C.x=3,y=2
D.x=3,y=3

A.h)
B.h)
C.x=2,y=2
B.x=2,y=3
C.x=3,y=2

【参考答案】

B
解析: 由主函数入手,定义了类TestClass的对象s1(2,3),当类对象进入其作用域时调用构造函数,构......

(↓↓↓ 点击下方‘点击查看答案’看完整答案 ↓↓↓)