Pergunta de entrevista da empresa Qualcomm

what is difference between static , const and void

Resposta da entrevista

Sigiloso

27 de out. de 2011

void - nothing; generally used in conjunction with function return type .compilers donot allow to declare a void variable. They do allow for a void pointer - void *. but you cannot do any thing to it unless memory has been allocated to it. const - once assigned value can never be modified. these kind of variables gets stored in text area of the process stack. if a declaration of a variable is prefixed with const then that means it is not modifiable by the code. static - used for variables to be visible only in file. values of these variable persist across function calls. get stored in data area of process map. volatile - used to tell compile that these variables are not in CPU's control and do not generate any kind of optimization based on these variables. const volatile - not under CPU control and cannot be changed by code. can only be changed by an external hardware (memory mapped h/w)