What is the difference between the iterators defined here.

vector vec;
//put 10 values into vec
const vector::iterator p = vec.begin();
vector::const_iterator q = vec.begin();


The difference here is what we are promising not to change. With regard to p, it is p itself that can’t be changed. With q, it is what q points to that can’t be changed.
Example:
*p = 0; //OK to change vec where p points,
p = vec.end();//error: l-value specifies const object
//can’t change p itself
q = vec.end();//OK to change q
*q = 0; //error l-value specifies const object
//can’t change vec where q points.

Computer Science & Information Technology

You might also like to view...

Class String and the Char structure are found in the:

a) System.Strings namespace b) System.Chars namespace c) System.Text namespace d) System namespace

Computer Science & Information Technology

Which of the following refers to the amount of horizontal space between characters?

A) Character spacing B) Scaling C) Kerning D) Position

Computer Science & Information Technology

Which protocol enables operating systems and applications to access directories?

A. SNMP B. SAMBA C. SMB D. LDAP

Computer Science & Information Technology

Small slices of a data mart are called data warehouses.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology