Finding size of dynamically allocated array

前端 未结 7 625
礼貌的吻别
礼貌的吻别 2020-12-10 11:08

Why is it not possible to get the length of a buffer allocated in this fashion.

AType * pArr = new AType[nVariable];

When the same array is

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-10 11:46

    No, not really. At least not in a platform-independent, defined way.

    Most implementations store the size of a dynamically allocated array before the actual array though.

提交回复
热议问题