#include // for EXIT_SUCCESS #include // for std::cout, std::endl #include // for std::shared_ptr #include // for std::vector using std::shared_ptr; using std::vector; int main(int argc, char** argv) { vector > vec; vec.push_back(shared_ptr(new int(9))); vec.push_back(shared_ptr(new int(5))); vec.push_back(shared_ptr(new int(7))); // z is (a reference to) the (int pointed to by the shared_ptr // in vec[1]) int &z = *vec[1]; std::cout << "z is: " << z << std::endl; // removes the last element of the vector and deallocates it (7) vec.pop_back(); return EXIT_SUCCESS; }