Which of the following could you use to declare the iterator p? Why?

Suppose you want to run code that involves the loop
```
//Assume vector v and iterator p has been defined and
//given appropriate values
for (p = v.begin(); p != v.end(); p++)
cout << *p << “ “;
```

```
std::vector::iterator p;
std::vector::const_iterator p;
```


You could use either, but you probably should use const_iterator. In the loop, the iterator p is used to fetch from the container. There is no code that would change the container’s contents.

Computer Science & Information Technology

You might also like to view...

Under which law must healthcare enterprises guard protected health information and implement policies and procedures to safeguard it, whether it be in paper or electronic format?

A. Sarbox B. COPPA C. GLBA D. HIPAA

Computer Science & Information Technology

On the Layers panel, artwork on a top layer appears ____artwork on layers beneath it.

A. above B. behind C. in front of D. under

Computer Science & Information Technology

When using WordArt, special effects are applied to the text itself, not to the shape surrounding the text

Indicate whether the statement is true or false

Computer Science & Information Technology

The ComboBox control combines a TextBox with a control.

a) DateTimePicker b) ListBox c) NumericUpDown d) Label

Computer Science & Information Technology