2. As presented in the previous questions figure, you are expected to copy objects from v1 and v2 to each other rather than integer values. In this question, you are asked to write a C++ program that performs certain operations on vectors of objects. The program should include the following components: A. A 'human class with the following specifications: - Two public member variables: 'height' (an integer) and `name` (a string). - A constructor that takes two parameters: an integer for the 'height' and a string for the `name`. The constructor should have default values of '0' for the 'height' and an empty string for the `name`. - A 'display()' member function that prints the `name` and 'height' to the console. B. A function named 'CopyValues()` that takes two vectors of 'human' objects as parameters by reference. The function should perform the following operations: - Check if the sizes of the two vectors are equal. - If they are, iterate over the first six elements of the vectors. - For the first three elements, copy the value from the corresponding element in the second vector to the first vector. - For the next three elements, copy the value from the corresponding element in the first vector to the second vector. C. In the main() function: - Create two vectors of 'human' objects, `vl` and `v2`, with specific values. vector v1 = {human(), human(), human(), human(170,"ali"), human(180,"ahmet"),human(190,"can")}; vector v2 = {human(140,"fatma"), human(150,"ayse") ,human(160,"selin"), human(), human(), human()}; - Call the 'Copy Values() function to modify 'vl' and `v2`. - Print the contents of 'vl' and `v2` using the `display()` member function of the 'human' class. V1 22 V2 000000
2. As presented in the previous questions figure, you are expected to copy objects from v1 and v2 to each other rather than integer values. In this question, you are asked to write a C++ program that performs certain operations on vectors of objects. The program should include the following components: A. A 'human class with the following specifications: - Two public member variables: 'height' (an integer) and `name` (a string). - A constructor that takes two parameters: an integer for the 'height' and a string for the `name`. The constructor should have default values of '0' for the 'height' and an empty string for the `name`. - A 'display()' member function that prints the `name` and 'height' to the console. B. A function named 'CopyValues()` that takes two vectors of 'human' objects as parameters by reference. The function should perform the following operations: - Check if the sizes of the two vectors are equal. - If they are, iterate over the first six elements of the vectors. - For the first three elements, copy the value from the corresponding element in the second vector to the first vector. - For the next three elements, copy the value from the corresponding element in the first vector to the second vector. C. In the main() function: - Create two vectors of 'human' objects, `vl` and `v2`, with specific values. vector v1 = {human(), human(), human(), human(170,"ali"), human(180,"ahmet"),human(190,"can")}; vector v2 = {human(140,"fatma"), human(150,"ayse") ,human(160,"selin"), human(), human(), human()}; - Call the 'Copy Values() function to modify 'vl' and `v2`. - Print the contents of 'vl' and `v2` using the `display()` member function of the 'human' class. V1 22 V2 000000
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 1 images