[SDL] Re: SDL and std::vector not mixing well...

Alex Volkov avcp-sdlmail at usa.net
Mon Nov 7 12:09:58 PST 2005


Nick Stovall wrote:
> http://rafb.net/paste/results/amotZe10.html
> Here you go, this is the entire header that I've declaired the vector in.
>
>Replacing vector<int> m_vFrameTracker with
>vector<int> m_vFrameTracker( *number*) doesn't do any good, it still
crashes.
>
>I just tested it, and declairing a vector in main() works just fine, the
>program runs nicely and every. Declairing it as a member of a class is
what's
>causing the errors.

My C++ might be a little rusty, but what exactly are you trying to do with
class CBaseEngine
{ ....
vector<int> m_vFrameTracker(1);
.... }
?
That would be the syntax for constructing a vector<int> with 1 element. You
cannot construct anything within the class declaration. Instead, it should
be declared as --
	vector<int> m_vFrameTracker;
and constructed like so --
CBaseEngine::CBaseEngine() : m_vFrameTracker(1) {}

-Alex






More information about the SDL mailing list