Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Make this compile

Name: Anonymous 2010-11-08 22:38

I can't change the integers to public, just ADD something to make this compile


class X
{ private: int x;
public: X(int i){x=i;}
};

class Y{ private: int y;
public: Y(int i){y=i;}
};

int operator +(X &p1, Y &p2){return p1.x+p2.y;};

Name: Anonymous 2010-11-09 4:25


class X
{ private: int x;
public: X(int i){x=i;}

friend int operator +(X &p1, class Y &p2);
};

class Y{ private: int y;
public: Y(int i){y=i;}
friend int operator +(X &p1, Y &p2);
};

int operator +(X &p1, Y &p2){return p1.x+p2.y;};


Don't mind me. Just doing your homework.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List