- Examples
Explore static methods that operate without class instances, understand the this pointer for distinguishing object members, and learn how const and constexpr methods control data access and enable compile-time evaluation in C++ classes.
We'll cover the following...
We'll cover the following...
Static methods #
Explanation #
-
The static attribute,
deposits, is being initialized on line 8. Whenever the constructor is called, its value is incremented by1. -
On lines 22 and 29, we can see that the static
getDeposits()method can be called without an instance ofAccount. -
After the creation of
account1andaccount2, the value ofdepositsis incremented to2. We can check this by invokinggetDeposits()...