Class Anatomy

Class Structure:

C++ classes have a rich set of functions and operators that allow a designer to provide an expressive and effective language other code uses to invoke class operations. This section explores C++ class structure in detail. Most of that detail you will find in the linked presentation and code examples.

Str.h

A class declaration declares, and may define, member functions and member state on which the member functions act.

A member function definition defines a single copy of code, placed in static memory, that serves all instances of the class.

Non-static member data declarations declare, and may define, data held in each instance of the class. The values of that data are unique to each class instance.

Static member data declarations declare a single copy of data for each declaration, placed in static memory, that serve all instances of the class. That is, each instance sees the same value of the static data.

Static data members must be defined below the class declaration. If you don't do this, no memory is reserved in static memory for the data and you will get linker errors when you build the package containing the class.

Preliminaries:

First, we prime the pump with some relatively simple examples, then ...

A detailed example:

If you understand this Str Class code, you will have learned almost everything you need to know about the implementation of a single class. We will look carefully at the declaration, definition, and invocation of each of the Str class's member functions. We do that in this presentation, ppt.

A Next Day beginning note: