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 0:38

>>14
>I can't change the integers to public
Oh MB.
new updated version

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

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

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

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