jjzjj

myotherints

全部标签

c++ - 为什么用 new 创建的 C++ 数组与 C 样式数组的行为不同?

我正在自学C++,因此一直在编写一些示例代码来真正巩固我对指针和数组的理解。我是这样写的:intmyints[]={20,40,60,80,100};//Cstylearray?shouldbestoredonstack?ismyint'stypepointertointoranarrayofint?howdoesitdifferfrommyotherints?int*myotherints=newint[5]{20,40,60,80,100};//newalwaysreturnspointer,isthisaC++stylearray?//doesthispointergetcrea