首页 > 试题广场 >

阅读下列程序,写出运行结果: #include usin

[问答题]
阅读下列程序,写出运行结果:
#include<iostream>
using namespace std;
class A
{
public :
     int f1();
     int f2();
     void setx( int m ) { x = m; cout << x << endl; }
     void sety( int n ) { y = n; cout << y << endl; }
     int getx() { return x; }
     int gety() { return y; }
  private :
     int x, y;
};
int A::f1()
{ return x + y; }
int A::f2()
{ return x - y; }
int main()
{
A a;
   a.setx( 10 );    a.sety( 5 );
   cout << a.getx() << '\t' << a.gety() << endl;
   cout << a.f1() << '\t' << a.f2() << endl;
}

推荐
10
5
10        5
15        5
发表于 2018-05-07 15:07:42 回复(0)