#include //#include #include "vec.h" int main(){ // Vec is a template, not a type. Vec teams; teams.push_back("rpi"); teams.push_back("wpi"); teams.push_back("yale"); teams.push_back("brown"); teams.push_back("cornell"); teams.push_back("colgate"); teams.push_back("miami"); teams.push_back("colorado"); teams.push_back("harvard"); // we can use a type alias defined inside a class even if there is no object of that class. The type alias becomes part of the class's scope and can be used anywhere in your code where the class's scope is visible. although no object of Vec is created in this code, the type alias size_type is still accessible because it is part of the class's scope. for(unsigned int i = 0; i < teams.size(); i++){ std::cout << teams[i] << std::endl; } std::cout<<"========="< v(4, 0.0); v[0] = 13.1; v[2] = 3.14; // copy a vector - calls copy constructor. Vec u(v); u[2] = 6.5; u[3] = -4.8; for (unsigned int i = 0; i < v.size(); ++i){ std::cout << "u[" << i << "] is " << u[i] << " and v[" << i << "] is " << v[i] << std::endl; } std::cout<<"========="< w(v), w is a copy of the elements in v. Vec w = v; for (unsigned int i = 0; i < v.size(); ++i){ std::cout << "w[" << i << "] is " << w[i] << " and v[" << i << "] is " << v[i] << std::endl; } std::cout<<"========="< y; y = v; for (unsigned int i = 0; i < v.size(); ++i){ std::cout << "y[" << i << "] is " << y[i] << " and v[" << i << "] is " << v[i] << std::endl; } std::cout<<"========="<