注册 登录
编程论坛 VC++/MFC

求助编译出错怎么回事??坐等

zhaoya881010 发布于 2010-12-29 16:04, 584 次点击
程序:
程序代码:
#include <iostream>

using namespace std;


class Point
{
   public:
      Point(int xx=0, int yy=0)   {X=xx; Y=yy; cout<<"The construct fun called"<<endl;}
      Point(Point& p);
  //    Point(Point p);
      int GetX()   {return X;}
      int GetY()   {return Y;}

 //     Point& test(Point& a);
   private:
      int X, Y;
};


Point::Point(Point& p)
{
    X=p.X;
    Y=p.Y;
    cout<<"The copy construct fun called 11111"<<endl;
}

/*
Point::Point(Point p)
{
    X=p.X;
    Y=p.Y;
    cout<<"The copy construct fun called 22222"<<endl;
}
*/


Point test(Point a)
{
       cout<<"test"<<endl;
    return a;
}



int main(int argc , char** argv)
{
    Point box1(2, 2);
    cout<<"first"<<endl;
    Point box2=box1;
    cout<<"second"<<endl;
    Point box3(box1);
    cout<<"third"<<endl;
    Point box4;
    cout<<"forth"<<endl;

    box4=box1;
      
    cout<<"fifth"<<endl;
    test(box3);
    box2=test(box3);//出错!
    Point box5=test(box3);//出错!
    return 0;
}

3 回复
#2
qq10235692232010-12-29 16:35
不懂
#3
ytchfp2010-12-30 10:15
没有错,可能是你装的版本有问题。
#4
shafeilong2010-12-30 13:13
我这里运行的好好的
1