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

Pages: 1-

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-08 22:56

Added two slashes.

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-08 23:03

>>2
nice troll

Name: Anonymous 2010-11-08 23:11


#define private public

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;};

int main(){return 0;}

Name: Anonymous 2010-11-08 23:24

OP HERE
i forgot something, i must add stuff ONLY inside X and Y

Name: Anonymous 2010-11-08 23:28

You could try compiling it as whitespace.

Name: Anonymous 2010-11-08 23:31

>>6
i don't think so, this problem is a challenge and that feels like cheating, someone said something about class friendship but i couldn't use that at all

Name: Anonymous 2010-11-08 23:34

btw this shit was int my first Algorithms and Data Structures I exam

Name: Anonymous 2010-11-08 23:53


struct X
{  int x;
 X(int i){x=i;}
};

struct Y{  int y;
 Y(int i){y=i;}
};

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

Fixxxed

Name: Anonymous 2010-11-09 0:02

>>9
wrong answer

Name: saga 2010-11-09 0:04

>>10
Why?

Name: Anonymous 2010-11-09 0:12

>>11
int x and int y are private you can't remove definitions you can just ADD more stuff

Name: Anonymous 2010-11-09 0:12

>>7
Well maybe if you had any friends in class they'd tell you the answer.

Name: Anonymous 2010-11-09 0:12

>>11
Because you're a [spoiler]``faggot''[.spoiler]
and as if it wouldn't be enough your violated
>I can't change the integers to public

Charge him!

Name: Anonymous 2010-11-09 0:13

>>13
>friends
>CS class
you better be trolling

Name: Anonymous 2010-11-09 0:16

>your violated

Oh fuck, no. I shouldn't read youtube comments anymore. They make me stupid.

Name: Anonymous 2010-11-09 0:36

OP HERE, come on guys, i thought you were the best

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();};

Name: Anonymous 2010-11-09 0:41

>>18
 i must add stuff ONLY inside X and Y, i cant change change "int operator +(X &p1, Y &p2){return p1.x+p2.y;}; "

Name: Anonymous 2010-11-09 0:47

OP HERE, okay i'll try to explain clearly all the rules for this :
First of all you cnn only add stuff inside the two classes, you can't remove nothing, you can't change nothing, okay?

Name: Anonymous 2010-11-09 1:16

So what do you want it to compile?

Name: Anonymous 2010-11-09 1:55

>>21
OP HERE my homework

Name: Anonymous 2010-11-09 2:08

OP HERE
You really don't have to do that. In fact, it's quite obnoxious.

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.

Name: Anonymous 2010-11-09 4:30

Oh, Bjarne.

Name: Anonymous 2010-11-09 8:04

>>23
NOT OP HERE your a faggot

Name: Anonymous 2010-11-09 9:10

>>24
thanks

Name: Anonymous 2010-11-09 9:25

>>24
YOU HELPED HIM!!!

Name: Anonymous 2010-11-09 13:40

/prog/ is nothing less than /b/... It simply sucks, and it sucked since the Internet was young. And you, bitches, still don't get it.

In the last week I've tried to post some useful questions, and check how good /prog/ is... The only thing that I've noticed is a lot of dumbfags posting SICP and FIOC . You are clueless dogshit, and there's nothing to do about it.

This thread simply confirms my thesis.

Name: Anonymous 2010-11-09 13:45

>>29
No, no. I followed a link to some archive, and tried sitting through a thread about ordering pizza. Needles to say, I failed.
/b/ is far worse, and I'm pretty sure I have bitch tits.

Name: Anonymous 2010-11-09 23:09

>>29
back to /b/, please

Name: Anonymous 2010-12-17 1:32

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Name: Anonymous 2011-01-31 19:56

<-- check em dubz

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