< Previous | Contents | Next >

Summary

In this chapter, you learned the following concepts:

n The for loop lets you repeat a section of code. In a for loop, you can provide an initialization statement, an expression to test, and an action to take after each loop iteration.

n for loops are often used for counting or looping through a sequence.

n Objects are encapsulated, cohesive entities that combine data (called data members) and functions (called member functions).

n string objects (often just called strings) are defined in the file string, which is part of the standard library. string objects allow you to store a sequence of characters and also have member functions.

n string objects are defined so that they work intuitively with familiar operators, such as the concatenation operator and the relational operators.

Questions and Answers 111


n All string objects have member functions, including those for determining a string objects length, determining whether or not a string object is empty, finding substrings, and removing substrings.

n Arrays provide a way to store and access sequences of any type.

n A limitation of arrays is that they have a fixed length.

n You can access individual elements of string objects and arrays through the subscripting operator.

n Bounds checking is not enforced when attempts are made to access individual elements of string objects or arrays. Therefore, bounds checking is up to the programmer.

n C-style strings are character arrays terminated with the null character. They are the standard way to represent strings in the C language. And even though C-style strings are perfectly legal in Cþþ, string objects are the preferred way to work with sequences of characters.

n Multidimensional arrays allow for access to array elements using multiple subscripts. For example, a chessboard can be represented as a two-dimensional array, 8 8 elements.