In the file related examples so far we have not concerned ourselves with error situations. In particular, we have assumed that the error handling in file we opened for reading already existed, and that those opened for writing...
Category - Language C
Most programs need to save data to disk file I/O and read it back in. Working with disk file I/O requires another set of classes: ifstream for input, fstream for both input and output, and of stream for output. Objects of these...
In this section we’ll introduce a new kind of unified modeling language UML diagram: the state diagram (also called the statechart diagram). The UML class diagrams we examined in earlier chapters show relationships between...
Our next example demonstrates an array of pointers to objects, and shows how to sort these pointers based on data in the object. This involves the idea of pointer to pointer, and may help demonstrate why people lose sleep over...
Memory Management : We’ve seen many examples where arrays are used to set aside memory. The statement int arr1[100]; reserves memory for 100 integers. Arrays are a useful approach to data storage, but they have a serious...
Before we noted that there are three ways to pass arguments to a function: by value, by reference, and by pointer. If the passing pointers to functions in C++ is intended to modify variables in the calling program, these...
There is a close association between pointers and arrays. “Arrays and Strings,” how array elements are accessed. The following program, ARRNOTE, provides a review. // arrnote.cpp // array accessed with array...
Overloading binary operators can be overloaded just as easily as unary operators. We’ll look at examples that overload arithmetic operators, comparison operators, and arithmetic assignment operators. Arithmetic Operators In the...
Let’s start off by overloading a unary operators. unary operators act on only one operand. (An operand is simply a variable acted on by an operator.) Examples of unary operators are the increment and decrement operators ++ and...
We noted at the beginning of this chapter that two kinds of strings are commonly used in C++: C-strings and strings that are objects of the string class. In this section we’ll describe the first kind, which fits the theme of...
















