Summary
In this chapter, you should have learned the following concepts:
- 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.
- ‘for’ loops are often used for counting or looping through a sequence.
- Objects are encapsulated, cohesive entities that combine data (called ‘data members’) and functions (called ‘member functions).
- ‘string’ objects (often just called ‘string’) 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.
- ‘string’ objects are defined so that they work intuitively with familiar operators, such as the concatenation operator and the relational operators.
- All ‘String’ object have member functions, including those for determining a ‘string’ object’s length, determining whether or not a ‘string’ object is empty, finding substrings, and removing substrings.
- Arrays provide a way to store and access sequence of any type.
- A limitation of arrays is that they have fixed length.
- You can access individual elements of ‘string’ objects and array though the subscripting operator.
- 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 programming.
- C-style string are character arrays terminated with the null character. They are the standard way to represent string in the C language. And even though C-Style strings are perfectly legal in C++, ‘string’ objects are the preferred way to work with squences of characters.
- Multidimensional arrays allow for access to array elements using multiple subscripts. For example, a chessboard can be represented as a two-dimensional array, 8 X 8 elements.