What is the difference between const and static in c++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the difference between const and static in c++?

c++

20th Jan 2018, 6:27 PM
Amit Pokhrel
1 Answer
+ 3
you can have multiple static variables in different c++ source code files with the same name and no name conflicts.const is just constant, meaning can't be modified. A static variable can get an initial value only one time. ... As such, static variables are only initialized once. -stackoverflow
20th Jan 2018, 6:35 PM
emmey
emmey - avatar