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

前端 未结 7 771
再見小時候
再見小時候 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:38

    A member variable belongs to an object... something which has state. A local variable just belongs to the symbol table of whatever scope you are in. However, they will be represented in memory much the same as the computer has no notion of a class... it just sees bits which represent instructions. Local variables and member variables can both be on the stack or heap.

提交回复
热议问题