What is the difference between a static and const variable?

前端 未结 17 1758
天命终不由人
天命终不由人 2020-11-29 18:39

Can someone explain the difference between a static and const variable?

17条回答
  •  遥遥无期
    2020-11-29 18:48

    Const means “cannot be changed.”

    Static means “static instance (in memory) vs dynamic instance (on the stack.)” Static variables exist for the duration of the program. Dynamic ones are created and destroyed as needed.

    A variable can be one or both.

提交回复
热议问题