Which of the following shows the contents of vector pointed by v1 and v2 after running this code?

Advertisement

std:: vector<int> *v1 = new std::vector<int>({1,2,3});
std:: vector<int> *v2;
v2=v1;
v1->push_back(4);
v2->push_back(5);

  • *v1:{1,2,3,4}; *v2:{5};
  • *v1:{1,2,3,4,5}; *v2:{1,2,3,4,5};
  • Error
  • *v1:{1,2,3,4}; *v2:{1,2,3,5};
Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

Leave a Comment

Share via
Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.