... vector foo; ... ... void addObject() { Object a; a = new Object; foo.push_back(a); }