P. 1
Vectors in Cpp

Vectors in Cpp

|Views: 28|Likes:
Published by Emperor Saladin
A PDF that gives you basic outline of what you can do with vectors in C++. It includes inputs, outputs and ways to manage data in a vector.
A PDF that gives you basic outline of what you can do with vectors in C++. It includes inputs, outputs and ways to manage data in a vector.

More info:

Published by: Emperor Saladin on Feb 20, 2013
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

02/20/2013

pdf

text

original

Make a greater than operator

Assignment Problems
A dynamic array, that you can add and remove entries from A type of container

Use unsigned int because v1.size() returns unsigned int. Iterator is a pointer Vector<thing>::iterator it; Acts like an array vector[5]; vector[5] = 10;

What is it? Iteration

Cheap adding at the end

Vectors in C++

Memory

Adding too much can become slow Needs to copy data to another place

Will throw exception
vector.at(); front(); back(); Resize push_back pop_back Add Memory Add/Remove Element Safer Access

Data Modification Declaration and Initialization
vector<type> varName ( initialSize , initialValue ); Good to keep initial value

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->