I am trying to declare a global vector of MyClass using unique_ptr.
*glo.h
extern std::unique_ptr<std::vector<MyClass>> gl_vec;
*glo.cpp
std::unique_ptr<std::vector<MyClass>> gl_vec;
And in the file where I initialize and use it for the first time in a different *.cpp file:
#include "glo.h"
gl_vec = std::unique_ptr<std::vector<MyClass>> ();
cout << "gl_vec size = " << (*gl_vec).size() << endl; // crashes here
Things keep crashing when I use the pointer. Anyone see what I'm doing wrong?
Aucun commentaire:
Enregistrer un commentaire