Are references stored on the heap or stack?

后端 未结 4 666
被撕碎了的回忆
被撕碎了的回忆 2021-01-12 02:44

I wonder whether the reference variables such as c in this code:

int a = 5;
int & c = a;

are allocated from heap or stack.

4条回答
  •  臣服心动
    2021-01-12 03:15

    References are just aliases and do not have to be allocated anywhere in particular. The standard doesn't specify this kind of detail, to the point where it isn't even required that references have any storage at all.

提交回复
热议问题