问题
填空题
下列程序的运行结果是 [12] 。 include <iostream. h> class Sample {int x,y;public: Sample() {x=y=0; } Sample(int a, int b) {x=a;y=b;} void disp() {cout<<" x=" <<x<<" , y="<<y<<end1;} }; void main() { Sample s1, s2(1, 2); s1. disp0; s2. disp (); }
答案
参考答案:此程序的运行结果为:
解析:x=0, y=0 x=1, y=2