What is the difference between const & static keyword?
sheetal sawant
Static object or variable is stored on the data segment area of memory and the same value is get shared by all the objects/variables While Const is Just a name of that assigned value which cant be changed.and replaced at all the location by compiler while compilation.
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.