I have a small problem with C++ vector. In my .H file i have
class MyClass{
private:
std::vector<myObject> test;
public:
MyClass();
add(myObject object);
}
In my .CPP file
MyClass::MyClass(){
std::vector<myObject> test;
}
MyClass::add(myObject object){
//here is the problem. Netbeans does even giving me quick cast this method i need to write it myself and it throws an error.
test.push_back(object);
}
I am using NetBeans 8 and it says "Unable to resolve identfier push_back and I don't know why. I'm pretty new to C++ and done some research but it seems like I can't find the answer. My goal is to have .H file and i initialize vector in .CPP and then i want to have separate function like add to push my objects to this class that contains a vector. Something like a list where you can add your objects.
Thank You for help.
EDIT: And yes I include vector at the top.
Aucun commentaire:
Enregistrer un commentaire