单选题 下列程序的执行结果是______。
#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<<ecdl;
}
};
void main()
{
TestClass s1(2,3);
s1.disp();
【正确答案】 B
【答案解析】[解析] 由主函数入手,定义了类TestClass的对象s1(2,3),当类对象进入其作用域时调用构造函数,构造函数应该是调用具有参数的“TestClass(inta,int b){x=a;y=b;}”,然后调用成员函数ditip(),则输出为“cout<<"x="<<x<<",y="<<y<<endl;”。即x=2,y=3。