All functions fail
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.
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.
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:
I think what you want to do is get rid of that evil temp variable and have something like this:
. . . 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;}
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement