28 lines
694 B
Plaintext
28 lines
694 B
Plaintext
== Inline static members ==
|
|
|
|
So this is the same idea as just having a static member variable/function for a
|
|
class. You just need to add inline in order to make it accessible outside the
|
|
.hpp file.
|
|
|
|
Another note about static members, under the hood they are the exact same as
|
|
globals that just happen to have the namespace of the class. Its exactly how
|
|
they act, however I didn't think that's how they worked at first. It gives you
|
|
an idea of what performance to expect though.
|
|
|
|
== Example ==
|
|
|
|
{{{C++
|
|
class foo {
|
|
public:
|
|
foo();
|
|
//...
|
|
|
|
static inline uint32_t get_count();
|
|
|
|
private:
|
|
static inline uint32_t count = 0;
|
|
};
|
|
}}}
|
|
|
|
[[C++]]
|