+ 2
What is use of static keyword in c++
C++ static keyword
2 Answers
+ 3
When used static keyword We donot need To initialize class to call function or variable.
+ 2
Static things store some information globally. You are not gonna refer to them through instances of class, but through the class itself.
You have instances of class Car and you have static integer numOfCars. You have to update it with only static functions and refering to them through the class as mentioned: Car::setNumOfCars(5) or Car::getNumOfCars()