Whether variable name in any programming language takes memory space

后端 未结 10 1510
时光说笑
时光说笑 2021-01-05 17:44

e.g.

int a=3;//-----------------------(1)

and

int a_long_variable_name_used_instead_of_small_one=3;//-------------(2)
         


        
10条回答
  •  被撕碎了的回忆
    2021-01-05 18:09

    The name you give to a variable in C/C++ will not affect the size of the resulting executable code. When you declare a variable like that, the compiler reserves memory space (in the case of an int on x86/x64, four bytes) to store the value. To access or alter the value it will then use the address rather than the variable name (which is lost in the compilation process).

提交回复
热议问题