All functions fail

Started by
3 comments, last by smart_idiot 19 years, 2 months ago
Hi everyone ! I am trying to make a little engine to support my application's main frame so that I can then concentrate on the game itself. The only problem is that everything seems to fail and my debugger doesn't tell me anything more than there is a segmentation fault somewhere but I'm not sure I can trust it (I'm using Dev C++ for now since MSV is not installed yet). Could anyone look at my code and tell me what's wrong ? Game.rar Edit by Fruny - Use HTML anchor tags to make hyperlinks.
Advertisement
Point::Point() : x(0), y(0){    temp = new Point;}


Oh, that's the funniest thing I've seen all day. What the heck do you think you're doing?

That's going to create another point, which will result in a point being created, which will result in another point being created, and this will keep going until you run out of stack space or memory, whichever happens first. Probably the stack.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
After looking around a bit more, I think what you're looking for is the this variable. Every object has one, it points to itself.

. . . Okay, I just looked again, I don't think that's why you wanted it. Looking at this:

Point& Point::operator+(const Point& copy) const{     (*temp).x = x+copy.x;     (*temp).y = y+copy.y;     return (*temp);}


I think what you want to do is get rid of that evil temp variable and have something like this:

Point & Point::operator+=(const Point& copy){ x += copy.x; y += copy.y; return *this;}Point Point::operator+(const Point& copy) const{ return Point(*this)+=copy;}
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
Ahh thanks a lot mate. My program now goes over all the steps but nothing shows again. Is there any other stupid mistake I made again ?!
I don't see anything obviously wrong, but I only looked at it, and I don't know a whole lot about Windows programming.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.

This topic is closed to new replies.

Advertisement