Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2350339
  • 博文数量: 816
  • 博客积分: 10000
  • 博客等级: 上将
  • 技术积分: 5010
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-17 17:57
文章分类

全部博文(816)

文章存档

2011年(1)

2008年(815)

分类:

2008-12-17 18:08:56

#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) |
给主人留下些什么吧!~~