KRHS Internet Lesson

Teacher Name:Mr. Rung                          Date of Lesson: March/April

Course Name: C++                    Lesson Name: Chap 14 - 1 to 3 Completion

Student Name

Password


Objective
To complete the workbook exercises.


Primary Focus
Read chapter 14 then answer the questions below.

Site Links
Course Home Page

Additional Resources

Site Links


1-1. Write a statement that will declare an array named Animals of type Zoo with 150 elements.
A TemplateExample Distances;
1-2. Write a statement that will declare an array named Data of type int with 7 elements. Initialize the ele- ments to: 5,34,1,89,5423,675,2342.
B The compiler will let you assign something at an index outside of the array, but you may be over- writing information that is needed.
1-3. What will happen if you try to assign a value to an index outside of the array?
C cout « Scores[5];
1-4. Write a statement that will set the first element in an array named Speed to 55.
D compiler simply plugs in the correct data type in each place the parameter appears.
1-5. Write a statement that will print to the screen the element in position five of the array Scores.
E Zoo Animals [150] ;
2-1. Why does using templates help a programmer save time?
F int Data[] = {5, 34, 1, 89, 5423, 675, 2342};
2-2. How does the compiler handle parameterized data types?
G an array that is essentially a list
2-3. Rewrite the statement to instanciate an object named Distances of type unsigned int. TemplateExample MyObject;
H one-dimensional array of any data type
3-1. Why are the subscript operators [ ] overloaded in the vector class?
I by: not having to rewrite code for each different data type, by not having to debug a new class or function, or by not having to design a new class.
3-2. For the purposes of this course, what is a vector?
J a variable in an array
3-3. Why is a vector class useful?
K Speed[0]=55;
3-4. List the vector class's private data and explain the purpose of each item.
L a two-dimensional array of any data type.
3-5. List the vector class's member functions and their purposes.
M a group of variables of the same data type that appear together in the computer's memory
v-1. array
N so that bounds checking can be done before something is assigned to that index of the vector.
v-2. element
O it provides bounds checking, it gives the array the ability to grow and shrink, and can return its length
v-3. one-dimensional array
P a class that can be used with any data type
v-4. template class
Q int mysize; // # elements in array
itemType * myList; // array used for storage
v-5. vector
R length: returns the length of the vector
resize: resizes the vector to the given size.