+ 2

What is use of static keyword in c++

C++ static keyword

17th Aug 2020, 8:54 AM
Yogesh Deolalkar
2 odpowiedzi
+ 3
When used static keyword We donot need To initialize class to call function or variable.
17th Aug 2020, 9:48 AM
Syed Rohaan Alam
Syed Rohaan Alam - avatar
+ 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()
17th Aug 2020, 10:04 AM
Jiří Zbořil (ZboraCZ)
Jiří Zbořil (ZboraCZ) - avatar