What is the difference between a member variable and a local variable?

前端 未结 7 778
再見小時候
再見小時候 2020-11-29 08:01

What is the difference between a member variable and a local variable?

Are they the same?

7条回答
  •  爱一瞬间的悲伤
    2020-11-29 08:45

    A local variable is the variable you declare in a function.Its lifespan is on that Function only.

    A member variable is the variable you declare in a class definition.Its lifespan is inside that class only.It is Global Variable.It can be access by any function inside that same class.

提交回复
热议问题