int gety() {return y;} private: int x, y; };
int A::f1() {return x+y;} int A::f2() {return x-y;} void main() {
A a;
a.setx(10); a.sety(5);
cout< 4、 # include T(int x, int y) { a=x; b=y; cout<<”diao yong gou zao han shu 1.”< } T(T &d) { 9 cout<<”diao yong gou zao han shu 2.”< cout<< d.a<<’\\t’< } ~T() {cout<<”diao yong xi gou han shu.”< int add(int x,int y=10) {return x+y;} private: int a,b; }; void main() { T d1(4,8); T d2(d1); cout< } diao yong gou zao han shu 1. 4 8 diao yong gou zao han shu 2. 4 8 20 20 diao yong xi gou han shu. diao yong xi gou han shu. 5、 #include double b; public: 10 A(int x=100,double y=1.2){a=x;b=y;} void show(char *pt) { cout< } }; void main() { A obj1,obj2(100,3.5); obj1.show(\ obj2.show(\ A *p; p=&obj1; p->show(\ (*p).show(\ p=&obj2; p->show(\ (*p).show(\ p=new A; p->show(\ delete p; } 6、 #include int x; 11 K (int i){x=i;} void fun1(int j){x+=j;cout<<\ void fun2(int j){x+=j;cout<<\ }; void main() { K c1(3),c2(6); void(K::*pfun)(int)=K::fun1; (c1.*pfun)(6); pfun=K::fun2; (c2.*pfun)(12); } 7、 #include } void DateTime(TIME &t); private: int year,month,day; }; class TIME { public: 12