HW #4 - the type int.) a. int list[5] = {2,4,6,8,10};...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
David Carothers CS 230 10/9/07 Exercises – Homework #4 1. What are the three main components of the STL? a. Containers b. Iterators c. Algorithms 2. What is the difference between an STL container and an STL iterator? a. While both are class templates, containers are used to manage objects of a given type, where as iterators are used to step through the elements of a container. 4. Write a statement that declares and stores the elements of the following array in to a vector object. Char vowls[5] = {‘a’,’e’,’i’,’o’,’u’}; a. vector<char> charVowls[5] = {‘a’,’e’,’i’,’o’,’u’}; 8. What is the output of the following program segment? (Assume the screen is an ostream iterator initialized to the standard output device to out put elements of
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: the type int.) a. int list[5] = {2,4,6,8,10}; vector<int> vecList(5);//declares vecList copy(list, list + 5, vecList.begin());//(copy from(start), copy from (end), copy to(destination)) copy(vecList.begin(), vecList.end(), screen); cout << endl; OUTPUT: 246810 10. What is the output of the following program segment? (Assume the screen is an ostream iterator initialized to the standard output device to out put elements of the type int.) a. Int list[5] = {2,4,6,8,10}; Vector<int> vecList(7); Copy(list, list + 5, vecList.begin()); Veclist.push_back(12); Copy(vecList.begin(), vecList.end(), screen); Cout << endl; OUTPUT: 2,4,6,8,10,12...
View Full Document

This note was uploaded on 02/21/2012 for the course COMPUTER CS 230 taught by Professor Idk during the Spring '12 term at Capitol College.

Page1 / 2

HW #4 - the type int.) a. int list[5] = {2,4,6,8,10};...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online