/////////////////////////////////////////////////////////////// // SimpleVector.cpp - demonstrate basic vector operations // // // // Jim Fawcett, CSE687 Demonstration, Jan 2001 // /////////////////////////////////////////////////////////////// // STL vectors are implemented as expandable arrays. // // This implies that for large vectors: // // - finding elements is always fast - random access // // - inserting an element is fast only near the end // // - deleting an element is fast only near the end // /////////////////////////////////////////////////////////////// #pragma warning(disable : 4786) #include #include #include using namespace std; //----< demonstrate simplest vector capabilities >------------- void main() { cout << "\n Demonstrate Simplest STL vector operations " << "\n ============================================\n"; cout << "\n ----------------------------" << "\n define a vector of strings " << "\n ----------------------------\n"; vector< string > demo1 { "first string", "second string", "third string" }; //demo1.push_back("first string"); //demo1.push_back("second string"); //demo1.push_back("third string"); for (auto item : demo1) cout << "\n " << item.c_str(); cout << endl; //int i; //for(i=0; i demo2 { 3.1415927, -3.5e-17, 5.777e+30 }; //demo2.push_back(3.1415927); //demo2.push_back(-3.5e-17); //demo2.push_back(5.777e+30); for (auto item : demo2) cout << "\n " << item; cout << "\n\n"; //for(i=0; i