//----------------------------------------------------------------- // Author: Zhixiang Chen // Class: CSCI/CMPE 2380, Spring 2009 // Lab 9: Play with iterator methods for a class (or container) // via the implementation of vector class template // Date: January 14, 2009 // Comment: The code here is meant to be revised. // //----------------------------------------------------------------- // // This lab exercise is practice iterator method for a class (or container). // An interator is just like a pointer to the class object, which can move via // address operations such as ++ and --, access the content pointed to by it via // dereference operator *, and do comparisons, etc. With with help of interator // method, it is inconvenient to move around a "list" of objects and to do insertion, // deletion operatioms, etc. // // Compile and run your program. When everything is fine, // print your .cpp and .h files and turn them to me or the TA. // ***************************************************************** #include < iostream > #include < fstream > #include < string > #include < cstring > #include < cmath > #include < cstdlib > #include < iomanip > //#include < vector > #include #include "lab2380_12_head.h" using namespace std; int main() { /********************************************************* Part A: Test interators *********************************************************/ myVector cat, //create a vector of size 10 dog; //create another vector of size 10 cat.push_back(20); //add 20 to the back cat.push_back(30); //add 30 to the back; cat.push_back(40); //add 40 to the back myVector::iterator itrOne; myVector::iterator itrTwo; itrOne = cat.begin(); //itrOne points to dog for changing itrTwo = dog.begin(); //itrTwo points to cat for accessing with changing for ( ; itrOne < cat.end(); itrOne++, itrTwo++) dog.push_back(*itrOne); cout<<"after copying cat to dog, the dog is .... " <