/* bar.h */
class bar{
/* standard stuff omitted */
std::vector foo;
};
/* bar.cpp */
bar::bar(){
// foo = new std::vector();
You do not need to use new
on foo
, since foo is a vector
, not a pointer to a vector
(i.e. std::vector<my_obj*> *foo
).
If you are coming from Java or C#, you may want to consider using std::vector<my_obj>
(a vector of objects) instead of a vector of pointers. It really depends on what you want to do.