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

When you specify a new parameter, you provide Alice with a name and a type.

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

Computer Science & Information Technology

Use the Report Wizard when you want to control the report's content and design

Indicate whether the statement is true or false

Computer Science & Information Technology

A program that looks benign but actually has a malicious purpose is a _______

a. Trojan horse b. Virus c. Worm d. Cookie

Computer Science & Information Technology

What does Access do to denote action queries differently in the Navigation Pane?

A. It displays them in bold text. B. It displays them in a section called Action queries. C. It displays them using specific icons. D. It displays them in a larger typeface.

Computer Science & Information Technology