Question: Generally, C++ Containers are designed to hold objects of a single type using templates. So, implement a heterogeneous container/Vector in C++. Example: int main() {
Generally, C++ Containers are designed to hold objects of a single type using templates. So, implement a heterogeneous container/Vector in C++.
Example:
int main()
{
Vector v;
v.add(5);
v.add(5.5f);
v.add("this");
for(int i = 0 ; i cout< cout << " Displaying an object of type Vector in a different way: "; Integer x; x = v.get(0); cout << x<<"\t"; // it prints 5 Float y; y = v.get(1); cout << y<<"\t"; // it prints 5.5 String s; s = v.get(2); cout << s << "\t"; // it prints this return 0; } We need the above main function to work correctly without any errors. Note: You can mimic the Java Vector class.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
