Understanding the C++ object model
C++ programs involve the creation, manipulation, and destruction of various entities known as objects. An object in C++ possesses several attributes such as type, size, storage duration, lifetime, alignment requirements, and value. The name of the object is optional.
The lifetime of the named object is bounded by its storage duration, and if the object doesn’t have a name, it is considered a temporary object. However, not all entities in C++ are considered objects. For example, the reference is one such non-object.
First, let’s take a brief look at the terminology because it is important to be aware of it, as it will help us in our daily work with the C++ language.
Declaration versus definition
In C++, the terms declaration and definition are often used to refer to different aspects of a variable, function, or class. Here’s what each term means:
- Declaration: A declaration introduces a name into a program and...