CPS 6, Ramm - Summer Semester I - 6/9/99 #14

Chap 7. Class Design and Implementation via Simulation

Chap 8. Arrays, Data, & Random Access

  • Vector Definition Syntax
    Vector<type> name;
    Vector<type> name(expression);
    Vector<type> name(expression, value);
    type is any with default (parameterless) constructor

  • Vector Initialization

    • Use Constructor
      • Vector<int> nums(4, -1);
      • Vector<string> words(12, "Hi");


    • Use Fill Member Function
      • Vector<int> nums(4);
      • nums.Fill(-1);
      • Vector<string> words(12);
      • words.Fill("Hi");

    • Use Client Program

  • Vector Parameters
    letters.cc
    • char type
    • functions tolower(char), isalpha(char)
    • get(char) member function
    • fail() member function

  • A Draft Word in Context Program
    context.cc

  • Redesigning a Word in Context Program
    Redesign in Classroom
    context2.cc

  • How to Solve Problem Without Vectors?