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...

The Track Changes view that indicates revisions by vertical red lines and comments by icons is:

a. All Markup b. No Markup c. Simple Markup

Computer Science & Information Technology

A resource is a file that is part of a running program and performs a specific task

Indicate whether the statement is true or false

Computer Science & Information Technology