Start here · Essential guide
Static Functions in C++
Learn how the static keyword works with functions in C++: file-only helpers and static member functions, with short examples you can compile and run.
Syntax and Functions
What static does to functions and variables and when to use it.
Start here · Essential guide
Learn how the static keyword works with functions in C++: file-only helpers and static member functions, with short examples you can compile and run.
A declaration tells the compiler a function's name and signature, while a definition adds the body. See how static changes linkage, with C++ examples.
Static variables keep their value for the whole program, while ordinary local variables are recreated on each call. See examples of both in C++.
Use static for file-only helpers, values that persist between calls, and shared class data. Learn when to use it in C++ and when another choice fits better.
The static keyword limits a name to its file, keeps values between calls, and attaches data to a class. Here is why C++ uses it and what each use does.
Related topics