Character sequences

The string class has been briefly introduced in an earlier chapter. It is a very powerful class to handle and manipulate strings of characters. However, because strings are, in fact, sequences of characters, we can represent them also as plain arrays of elements of a character type. For example, the following array:   char foo … Continue reading Character sequences

Name visibility

Scopes Named entities, such as variables, functions, and compound types need to be declared before being used in C++. The point in the program where this declaration happens influences its visibility: An entity declared outside any block has global scope, meaning that its name is valid anywhere in the code. While an entity declared within … Continue reading Name visibility

Ascii Codes

It is a very well-known fact that computers can manage internally only 0s (zeros) and 1s (ones). This is true, and by means of sequences of 0s and 1s the computer can express any numerical value as its binary translation, which is a very simple mathematical operation (as explained in the paper numerical bases). Nevertheless, … Continue reading Ascii Codes

Exceptions

Exceptions provide a way to react to exceptional circumstances (like runtime errors) in programs by transferring control to special functions called handlers. To catch exceptions, a portion of code is placed under exception inspection. This is done by enclosing that portion of code in a try-block. When an exceptional circumstance arises within that block, an … Continue reading Exceptions

Polymorphism

Before getting any deeper into this chapter, you should have a proper understanding of pointers and class inheritance. If you are not really sure of the meaning of any of the following expressions, you should review the indicated sections: Statement: Explained in: int A::b(int c) { } Classes a->b Data structures class A: public B … Continue reading Polymorphism