C++ new / new[], how is it allocating memory?

后端 未结 3 741
遥遥无期
遥遥无期 2021-01-26 17:09

I would like to now how those instructions are allocating memory.

For example what if I got code:

x = new int[5]; 
y = new int[5];

If t

3条回答
  •  日久生厌
    2021-01-26 17:52

    You didn't find it in the manual because it's not specified by the standard. That is, most of the time x and y will be side by side (go ahead and cout<< hex << their addresses).

    But nothing in the standard forces this so you can't rely on it.

提交回复
热议问题