Variable types with * prefix

In C++, a declaration introduces a name and its type to the compiler without necessarily allocating storage. A definition allocates storage for a variable or provides the implementation for a function or class, and thus is also by nature a declaration. Initialization gives an object its first value at the point of definition, while assignment changes the value of an already existing object later.

It is important to note that from the language semantics point of view, initialization and assignment are still different: initialization happens at object creation, while assignment happens afterward. The optimizer can sometimes make the generated code equivalent or even identical for simple types when the assignment follows the definition, but it does not change the semantic distinction.

2 Likes