class A{
Add(const B&);
vector <B*> vect;
};
A & A::Add(const B& obj){
vect.push_back(&obj);
return *this;
}
here I am getting fpermissive error, because argument of push_back is constant, how do I get rid of this?
I tried to create local copy in Add such as
B tmp;
tmp = obj;
vect.push_back(&tmp);
but I am not sure about this, as program step out of this method Add, tmp gets destructed, and adress in vector will point to invalid place in memory?