Lecture 3 - Slide 13 : 27
Vectors in C++
C++ has a flexible vector type, as an alternative to the C-like array facility
The C++ Prog. Lang. (3. edition)
:
Page 52, 442
The C++ Prog. Lang. (4. edition)
: Page 95-99
Arrays and pointers
Vector dokumentation at cplusplus.com
Vector characteristics:
A template class - type parameterized
Not of fixed size like an array - the number of elements may be adjusted dynamically
Size and capacity:
Size: The actual number of elements in the vector
Capacity: The maximum number of elements before resizing is needed
With or without range checking: The programmer's choice
Obeys
value semantics
If too expensive, pointers or references to vectors can be used
Traversed with use of
iterators
Iterators can be used in a similar way as pointers, via overloading of operators
*iterator
,
iterator++
,
iterator+n
,
iterator1-iterator2
Iterators
Understand Vectors