April 2017
Beginner to intermediate
394 pages
9h 16m
English
The first one, being used inside of a function, basically means that once the variable has been initialized, it will stay in the computer's memory until the end of the program, keeping the value that it has through multiple runs of the function. A simple example would be something like this:
#include <string> class StaticExamples { public: void InFunction() { static int enemyCount = 0; // Increase the value of enemyCount enemyCount += 10; std::string toDisplay = "\n Value of enemyCount: " + std::to_string(enemyCount); printf(toDisplay.c_str()); } };
Now if we were to call this, it would look something like the following:
StaticExamples se; se.InFunction(); se.InFunction();
And when we call ...
Read now
Unlock full access