





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






Range Percent Count 92 - 102 90-100 62 81.5 - 91.5 80-89 40 71.5 - 81 70-79 18 61 - 71 60-69 10 50.5 - 61.5 50-59 10 ≤ 50 ≤ 50 9
If you did not receive credit for Checkpoint 3 in last week’s lab (Lab 4), you may show it to a TA at the start of lab this week in order to earn credit. This applies to last week’s lab only.
Koenig & Moo: Chapter 5.1-5.
Based on our discussion of references and looking at the class declara- tion above, the question arises, what if we wrote:
string & fname = students[i].first_name(); fname[1] = ’i’
Would the code then be changing the internal contents of the i-th Student object?
const string & fname = students[i].first_name(); fname[1] = ’i’
The compiler would complain that you are trying to change a const object.
p = v.begin(); *p = 3.14; // changes 1st entry in v p = w.begin() + 2; *p = 2.78; // changes 3rd entry in w
are all valid because p is a vector
p = a.begin();
is a syntax error because of a type clash!
Vector (and string) iterators have special capabilities that other container iterators (list for now, but others later) do not have
p = v.begin() + i;
p = p + 5;
moves p 5 locations further in the vector.
Students are often confused by the difference between iterators and indices for vectors.
vector
*p = 6.0;
This has changed the contents of vector a.
cout << a[i] << endl;
to access and output the value stored at location 5 of a.
list