#include<iostream>
#include<string.h>
using namespace std;
class figure
{
int a;
double d;
public:
figure(int j,double m)
{
a=j;
d=m;
cout<<"CONS-sub"<<endl;
}
void sub_show()
{
cout<<"sub_object:"<<a<<"and"<<d<<endl;
}
~figure()
{
cout<<"Des_sub"<<endl;
}
};
class point
{
int x;
figure sub_obj;
public:
point(int a,int b,double d):x(a),sub_obj(b,d)
{
cout<<"CONS"<<endl;
}
void show()
{
sub_obj.sub_show();
cout<<"x="<<x<<endl;
}
~point()
{
cout<<"Des"<<endl;
}
};
int main()
{
point objp1(123,456,98.76);
cout<<"First object:"<<endl;
objp1.show();
point objp2=objp1;
cout<<"Second object:"<<endl;
objp2.show();
}
CONS-sub
CONS
First object:
sub_object:456and98.76
x=123
Second object:
sub_object:456and98.76
x=123
Des
Des_sub
Des
Des_sub
--------------------------------
Process exited after 0.939 seconds with return value 0
请按任意键继续. . .