注册 登录
编程论坛 C++教室

【求助】c++运算符重载

hhei 发布于 2009-07-26 11:34, 441 次点击
Point.h:
namespace main_savitch_2A
{
  class point
  {
    public:
      point(double x_amount,double y_amount)
      {
           x = x_amount;
           y= y_amount;
       }
      double get_x() const {reurn x;}
      double get_y() const { return y;}
      ostream& orerator << (ostream& outs,const point source);
    private:
       double x;
       double y;
}
..................
Point.cpp:
#include"Point.h"
namespace main_savitch_2A
{
      ostream& point ::operator << (ostream &out, const main_savitch_2A::point &source)
    {
        outs << source.get_x() << "" << source.get_y() << endl;
        return outs;
    }
}


编译的时候,总是说重载操作符那里的变量太多,那位达人知道是怎么回事啊,能否给个版本,简单写下就好
3 回复
#2
fjwddzzc1232009-07-26 11:59
ostream& orerator << (ostream& outs,const point source); point和source 掉了个&符号
#3
hhei2009-07-26 12:29
谢谢各位了,问题已经解决了。。。
#4
fjwddzzc1232009-07-26 12:48
就我一个人啊   哪来的各位  
1