What is the difference between const & static keyword?
sheetal sawant
Select an image from your device to upload
The copy of static variable remains same or its shared among all the instance objects of a class
constant variable can not be modified after it defines and it can not be change any how throughout the program
refernce: msdn
A variable declared static in a function retains its state between calls to that function.
When modifying a data member in a class declaration, the static keyword specifies that one copy of the member is shared by all instances of the class. When modifying a member function in a class declaration, the static keyword specifies that the function accesses only static members.
The const keyword specifies that a variable's value is constant and tells the compiler to prevent the programmer from modifying it.
Declaring a member function with the const keyword specifies that the function is a "read-only" function that does not modify the object for which it is called.