with DEV-c++ .
class Point
{
public:
Point(int xx=0,int yy=0){X=xx,Y=yy;}
Point(Point&p);
int GetX()
{ return X; }
int GetY()
{ return Y; }
private:
int X,Y;
};
Point::Point(Point&p)
{
X=p.X;
Y=p.Y;
cout<<"Copy constructor called"<<endl;
}
int main()
{ void fun1(Point p);
Point fun2();
Point A(4,5);
Point B(A);
cout<<B.GetX()<<endl;
fun1(B);
B=fun2(); // HERE there is a problem
cout<<B.GetX()<<endl;
getch();
}
void fun1(Point p)
{
cout<<p.GetX()<<endl;
}
Point fun2()
{
Point A(1,2);
return(A);
}

New Topic/Question
Reply




MultiQuote





|