static specifier
From cppreference.com
Inside a class, declares members not bound to specific instances.
Contents |
[edit] Syntax
static class_attribute | |||||||||
static class_method | |||||||||
[edit] Notes
- static attributes must be defined outside the class
- static constant integral attributes can be defined inline (until C++11)
- inside static methods there is no this pointer
- static methods cannot have other class-specific function specifier as cv, virtual or explicit overrides
[edit] See also
[edit] Example
struct C { static void foo(); static int n; static const int m = 16; // inline inizialization }; int C::n = 0; // static attribute definition void C::foo() { // no reference to non-static members/methods can occur here }