C++ static member variable inline initialization
This is an easy C++ language-knowledge question that tests whether you understand the mechanics of static class members and how modern C++ has relaxed the traditional declaration/definition separation. It probes familiarity with a keyword that changes where and how static members can be initialized.
Historically, static member variables had to be declared inside the class and then defined and initialized outside it—a pattern that created boilerplate and potential linker issues. Modern C++ introduced a keyword that allows you to handle both steps in one place, inside the class definition itself. Knowing this keyword is essential for writing cleaner, more maintainable class designs.
- Declaration vs. definition of static members
- One Definition Rule (ODR) and its implications
- Class scope and storage class specifiers