Array Notes

Introduction

Arrays are multi-valued variables of a particular type.


Processing Arrays
Arrays in Functions

BEGINNING NEW MATERIAL FOR CPSC246


Multi-dimensional Arrays


Vectors Basics for how to use a vector
  1. Include the vector library
    #include<vector>
  2. Declare a vector to hold a type:
    vector<int> myVector;
  3. Add an element to the vector usig the push_back method
    myVector.push_back (43);
    myVector.push_back (81);
  4. Find the value of an element of the vector using the at method
    x=myVector.at(0); // x is assigned 43
  5. Find the size of a vector;
    x=myVector.size(); // x is assigned 2
  6. Remove the last element of a function from the vector
    myVector.pop_back();
    x=myVector.size(); // x is now 1
More vector info