#include
using namespace std;
class Three3d
{
public:
float x;
float y;
float z;
Three3d(float a,float b,float c);
friend Three3d operator+(Three3d left, Three3d right);
friend Three3d operator-(Three3d left,Three3d right);
void show();
};
Three3d operator+(Three3d left,Three3d right)
{
return Three3d(left.x+right.x,left.y+right.y,left.z+right.z);
}
Three3d operator-(Three3d left,Three3d right)
{
return Three3d(left.x-right.x,left.y-right.y,left.z-right.z);
}
inline Three3d::Three3d(float a,float b,float c)
{
x=a;
y=b;
z=c;
}
void Three3d::show()
{
cout<<"the new Three3d.x="< cout<<"the new Three3d.y="< cout<<"the new Three3d.z="<}
int main()
{
Three3d t1(50,20,10);
Three3d t2(10,10,5);
Three3d t3=t1+t2;
Three3d t4=t1-t2;
t3.show();
t4.show();
system("pause");
}
--------------------next---------------------
#include
using namespace std;
class Three3d
{
public:
float x;
float y;
float z;
Three3d(float a,float b,float c);
friend Three3d operator+(Three3d left, Three3d right);
friend Three3d operator-(Three3d left,Three3d right);
void show();
};
Three3d operator+(Three3d left,Three3d right)
{
return Three3d(left.x+right.x,left.y+right.y,left.z+right.z);
}
Three3d operator-(Three3d left,Three3d right)
{
return Three3d(left.x-right.x,left.y-right.y,left.z-right.z);
}
inline Three3d::Three3d(float a,float b,float c)
{
x=a;
y=b;
z=c;
}
void Three3d::show()
{
cout<<"the new Three3d.x="< cout<<"the new Three3d.y="< cout<<"the new Three3d.z="<}
int main()
{
Three3d t1(50,20,10);
Three3d t2(10,10,5);
Three3d t3=t1+t2;
Three3d t4=t1-t2;
t3.show();
t4.show();
system("pause");
}
--------------------next---------------------
阅读(1609) | 评论(0) | 转发(0) |