我正在自学C++,因此一直在编写一些示例代码来真正指出我对指针和数组的理解.
我写了这个:
int myints[] = {20, 40, 60, 80, 100};
// C style array? should be stored on stack? is myint's type pointer to int or an array of int? how does it differ from myotherints?
int* myotherints = new int[5]{20, 40, 60, 80, 100}; // new always returns pointer, is this a C++ style array?
// does this pointer get created on stack while the elements themselves are created in free heap?
int j = 5; // should be …Run Code Online (Sandbox Code Playgroud)