I the below code , could you please tell if the scope of point object in function getObjects() is valid or not. I am creating object in createObj() , so scope of object "p" is limited to createObj()....does vector take care of this using copy constructor ?
void getObjects()
{
vector<point> vec;
creatObj(vec);
// getting correct output for object allocated in vector vec.
}
void createObj(vector<point> &vec)
{
point p;
p.x=10;
p.y=20;
vec.push_back(p);
}