Re: Sorting the code && Storing the files.
Posted: Tue Oct 27, 2015 11:19 am
I don't have time to address all questions, so I just leave some points about the static keyword
In general, static means that something has a lifetime that extends across the lifetime of the entire run of the program. Static variables occupy memory addresses that lie next to the program code, in contrast to stack and heap variables.
Static Free Functions
Static free functions are functions which have "internal linkage". That means, that you get one copy of the static function for each .cpp file, where you're using it (actually for each translation unit, but that often boils down to the indiviual .cpp files). It gives the compiler more freedom for optimization.
Static Class Functions
Static class functions behave like free functions in the namespace of the encompassing class (there are subtle differences, but they are not relevant for you at the moment). They don't have an implicit "this" parameter, so they don't need an instanced object of the class in order to be called. Like SuperLED already said, you call them like this: ClassName::FunctionName(/*arguments...*/);
In general, static means that something has a lifetime that extends across the lifetime of the entire run of the program. Static variables occupy memory addresses that lie next to the program code, in contrast to stack and heap variables.
Static Free Functions
Static free functions are functions which have "internal linkage". That means, that you get one copy of the static function for each .cpp file, where you're using it (actually for each translation unit, but that often boils down to the indiviual .cpp files). It gives the compiler more freedom for optimization.
Static Class Functions
Static class functions behave like free functions in the namespace of the encompassing class (there are subtle differences, but they are not relevant for you at the moment). They don't have an implicit "this" parameter, so they don't need an instanced object of the class in order to be called. Like SuperLED already said, you call them like this: ClassName::FunctionName(/*arguments...*/);