Im making a project for school and im stuck at this one part. Im trying to use a vector of objects that i defined. But i want the vector of objects to be declared inside a class declaration and then initialized inside the constructor of that class. Here is my code:
Code:
#ifndef MAP_H
#define MAP_H
#include "waypoint.h"
class Map
{
public:
Map();
~Map();
void initMap(); // this will create the ocean floor and water top in a glList
void DrawGround(GLfloat); // the y position that the ocean floor will be drawn
void DrawWaypoints();
private:
/* DISPLAY LISTS */
GLuint ground; // Storage For The net_box Display List
GLfloat floor_width;
GLUquadricObj *quadratic; // Storage for this->quadratic objects
std::vector<Waypoint> way_vec;
};
#endif
that is my class declaration called map.h. You can see i am declaring a vector of Waypoints which is a class i defined and included at the top of the file. Now in map.cpp where i declare my constructor i want to push Waypoint obejcts onto the vector like this:
Code:
...
#include "map.h"
Map::Map()
{
Waypoint test = Waypoint(10.0, 20.0, 6.0);
way_vec.push_back(test);
}
...
Now if i do that everything compiles fine but when i run the program in visual studio's 2005 i get a pop up error saying
"windows has triggered a breakpoint in pathfinder.exe
This may be due to the corruption of the heap, and indicates a bug in pathfinder.exe or any of the DLLs is has loaded.
The out put window may have more diagnostic information"
I really do not get why is is giving me this error. I think it has something to do with declaring a vector of waypoints in the class definition because if i just write in int main()
Code:
vector<Waypoint> way;
Waypoint obj = new Waypoint(10.0, 10.0, 2.0);
way.push_back(obj);
that works just fine.
Does anyone know what im doing wrong?