{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Vector_demo - An Example Using The Vector Class An example...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/*** An Example Using The Vector Class ***/ /*** An example program illustrating the functionality of the Vector class ***/ #include <fstream> #include "Vector.h" #include "MyString.h" using namespace std; ofstream output; void main () { output.open("demo_Vector.out"); // Create two String objects. String item1("CS XXX"), item2("Course Material"); // USING THE DEFAULT CONSTRUCTOR output << "Create array1, an empty Vector object with a default" << endl << "storage capacity = 10, using the default" << " constructor." << endl << endl; Vector<String> array1; // USING AddLast FUNCTION output << "Demonstrating AddLast, a useful member function, which" << endl << "adds a given item as the last item of the" << endl << "sequence." << endl << endl << "Add one after another the following four string objects" << endl << "to array1 using the AddLast function. " << endl << "\"CS XXX\",\"Course Material\",\"Using\",\"Vectors\"." <<endl; array1.AddLast(item1); array1.AddLast(item2); array1.AddLast("Using"); array1.AddLast("Vectors"); // USING THE SUBSCRIPT OPERATOR ( operator[] ) output << "Show the sequence of items in array1 using operator []." << endl << endl; for ( int i = 0; i < 4; i++ ) output << array1[i] << " ";
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern