12 Vectors and Vectors of Vectors, oh my!

12 Vectors and Vectors of Vectors, oh my! - Engineering101

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
Click to edit Master subtitle style Engineering 101 Vectors and Vectors of Vectors, oh my!
Background image of page 1

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

View Full DocumentRight Arrow Icon
Quote of the Day The High Life From building cars, planes, and trains To building drugs, plugs, and cranes, We exist on the fundamentals through struggle and pain, Doing math and science to help the world have less strain. With our video games and quirky jokes, All of us unite in someway until we croak. Our actions, though they cause some to jeer, Allow us to proudly say, “I am an engineer!”
Background image of page 2
Making Lists of Things n Often times we want to make lists of things  that are not characters n For these we can use another class called the  vector  class #include <vector>
Background image of page 3

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

View Full DocumentRight Arrow Icon
Vectors n Vectors can be used to make lists of anything:  int, double, char, string, …. n To declare a vector you have to specify the  type you are making a list of. vector <type> identifier;
Background image of page 4
Vectors n For example: vector <int> intlist; vector <double> doublelist; vector <string> stringlist;
Background image of page 5

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

View Full DocumentRight Arrow Icon
Vectors n Typically we also want to tell how long this list  will be: vector <int> intlist(5); vector <double> doublelist(10); vector <string> stringlist(25);
Background image of page 6
Vectors n We can also specify what to initialize the  values in the list to: vector <int> intlist(5, -1); vector <double> doublelist(10, 0.0); vector <string> stringlist(25, “none”);
Background image of page 7

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

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/07/2010 for the course ENGR engr 101 taught by Professor Rinenberg during the Spring '10 term at University of Michigan.

Page1 / 29

12 Vectors and Vectors of Vectors, oh my! - Engineering101

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online