首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ Builder >

高手,帮帮忙,该如何解决

2012-02-23 
高手,帮帮忙#pragmahdrstop#include iostream.h//---------------------------------------#pragmaargsu

高手,帮帮忙
#pragma   hdrstop
#include <iostream.h>
//---------------------------------------

#pragma   argsused
class   point{
                  int   x,y;
              public:
                  point(int   vx,int   vy)
                    {
                        x   =   vx;   y   =   vy;
                    }
                  point(){   x   =   0;   y   =   0;}

                  point   operator   +   (point   p1);
                  point   operator   -   (point   p1);
                  void   print(){cout < <x < < "   " < <y < < "\n ";
                };
point   point::operator   +   (point   p1)
{
    point   p;
    p.x   =   x   +   p1.x;
    p.y   =   y   +   p1.y;

    return   p;
}
point   point::operator   -   (point   p1)
{
    point   p;
    p.x   =   x   -   p1.x;
    p.y   =   y   -   p1.y;

    return   p;
}
int   main(int   argc,   char*   argv[])
{
            point   p1(10,10),p2(20,20);

            p1   =   p1   +   p2;


                return   0;
}

错误提示为:
++   Error]   Unit1.cpp(22):   E2238   Multiple   declaration   for   'point::operator   +(point) '
[C++   Error]   Unit1.cpp(17):   E2344   Earlier   declaration   of   'point::operator   +(point) '
[C++   Error]   Unit1.cpp(30):   E2238   Multiple   declaration   for   'point::operator   -(point) '
[C++   Error]   Unit1.cpp(18):   E2344   Earlier   declaration   of   'point::operator   -(point) '
[C++   Error]   Unit1.cpp(49):   E2040   Declaration   terminated   incorrectly

请问错误出在哪里???谢谢

[解决办法]
好隐蔽的错误:

void print(){cout < <x < < " " < <y < < "\n ";} //少了右大括号

热点排行