The dog class needs a copy ctor. That is at least one fatal issue which leads to disaster at push_back as copy of dog then is created. The default copy ctor will copy the pointers by value so they will point to the wrong (old) address. Enhanced dog class:
class dog {
public:
vector<meow> H;
vector<vector<meow>::iterator> HP;
dog() : HP(2), H(2)
{
HP[0] = H.begin();
HP[1] = H.begin() + 1;
}
dog(const dog& rhs) : H(rhs.H),HP(2)
{
HP[0] = H.begin();
HP[1] = H.begin() + 1;
}
dog& operator=(const dog& rhs)
{
if(&rhs==this)
return *this;
H=rhs.H;
HP[0] = H.begin();
HP[1] = H.begin() + 1;
}
};