Static members in .h and .cpp
Friend keyword
- A static variable in C++ when defined in a global function belongs to the file scope.
- If a C++ static variable is defined as a member variable, regardless of how many objects we instantiate we only have one static variable across all of the instances. The static variable can be accessed via the instance or the class variable.
- If a static variable is defined as member in a class declared in a .h file, the initialization should be done as [variable_type] ClassName::[variable_name] = [value]
- A static function can only access static variables - makes sense huh??
- A static function doesn't have the this pointer
- class_name::static_function() - usage
Friend keyword
Comments
Post a Comment