Where are variables in C++ stored?
问题 Where are variables in C++ stored? Inside the RAM or the processor's cache? 回答1: Variables are stored: on the stack, if they're auto -matic function-local variables on the heap, if they're allocated with new or malloc , etc. (details of what it means to say "a variable is stored in the heap" in the comments) in a per-process data area if they are global or static This is all in RAM, of course. Caching is transparent to userspace processes, though it may visibily affect performance. Compilers