"Game" crashes when instantiating object

Started by
10 comments, last by _Zac_ 12 years, 7 months ago

I edited the OP stating that I fixed it by using File.assign() instead of File=. Though I guess if you want to clarify:

std::string File

function(std::string n){File=n;}

The function is then called likeso:

function("name");

Why would File=n not work yet File.assign(n) does?




They look semantically the same, and references indicate such; std::string::assign() just offers more options and overloaded variants. Maybe an implementation detail? Try running it through a memory debugger.

And I was referring to your previous post. How is OnLoad() declared, and what is the returned string from File.c_str() when it breaks?
Advertisement
Alright, just checked again, and it actually does not work. Must of grown delirious when programming late at night and assumed it was fixed.

Anyway, File.c_str() doesn't work, but just putting in "./image.png" does, even though File.c_str() should equal the same thing. Since SDL stops you from outputting to the console I'm going to work on writing the strings to files like Ectara said.

OnLoad() (which is a part of CSurface) is declared as a static function. You put in a char array (or c-string as I think they're called) and then it returns a pointer to a surface. What's odd is that it seems to still return a not null value when it fails to load the surface.

EDIT: Ok, it's working again. I just made a stupid error that gave me some weird results. I'm pretty strung out right now though, so I'll work on what I want for awhile before I post another question here. Thanks again everyone.

This topic is closed to new replies.

Advertisement