From the course: C++ Essential Training

Unlock the full course today

Join today to access over 23,400 courses taught by industry experts.

Qualifiers

Qualifiers

- Qualifiers are used to adjust qualities of an object or a variable. This is an example of a variable declaration with qualifiers. In this example, the const and static keywords are the qualifiers. They tell the computer that this variable will be immutable. That's the const qualifier, and that it will have static storage duration. There are two types of qualifiers in C++, CV qualifiers and storage duration qualifiers. CV stands for constant and volatile. Const marks a variable as read only or immutable. It's value cannot be changed once it's been defined. Mutable is used on data members to make them writeable from a const qualified member function. I covered this in the companion course C++: Advanced Topics. Volatile marks a variable that may be changed by another process. This is rarely used and it's partly deprecated in C++ 20. It may be useful for external variables under very specific circumstances.…

Contents