Question: Using Vector in C++ Write a template function that takes as a parameter a vector of objects of some unknown class and two objects obj1

Using Vector in C++

Using Vector in C++ Write a template function that takes as a

Write a template function that takes as a parameter a vector of objects of some unknown class and two objects obj1 and obj2 of the same class. Modify the input vector to replace every instance of obj1 in the vector with obj2. If no instances of obj1 are found, add a new element at the end of the vector containing obj2. (Recall that you can access vectors like arrays, but they have useful methods like size and push_back. Vector declarations look like this: vector varName; Vectors are also covered further in the book in Section A.6.3 - page 707.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!