std::vector initialization problem

Get answers to all your basic programming questions. No Ogre questions, please!
Post Reply
Orc Shaman
Posts: 777
Joined: Mon Jan 18, 2010 6:06 pm
Location: Costa Mesa, California

std::vector initialization problem

Post by drwbns » Thu Sep 18, 2014 3:46 am

Hi guys, I'm trying to initialize a vector like this -

Code: Select all

std::vector<std::vector<hkReal>> *terrainVertices;
But I'm just getting a crash in the <vector> cpp file so I'm guessing there's something wrong here. Any thoughts on this one?
0 x

Posts: 6
Joined: Tue Jul 15, 2014 12:17 am

Re: std::vector initialization problem

Post by Alessan » Thu Sep 18, 2014 5:32 am


If you use a pointer, you must allocate memory for it.

std::vector<std::vector<hkReal>> *terrainVertices = new std::vector<std::vector<hkReal>>();
0 x

User avatar
OGRE Team Member
OGRE Team Member
Posts: 4116
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 243

Re: std::vector initialization problem

Post by dark_sylinc » Fri Sep 19, 2014 12:30 am

And don't forget to delete the memory afterwards.
0 x

Post Reply