📜  C++ 代码示例中的动态内存

📅  最后修改于: 2022-03-11 14:44:49.875000             🧑  作者: Mango

代码示例1
#include 

int main()
{
  int* ptr = new int(5);
  
  int* arr = new int[3];
  arr[0] = 96;
  arr[1] = 45;
  arr[2] = 72;
  
  std::cout << *ptr << "\n";// output: 5
  
  for (int i = 0; i < 3; i++)
  {
    std::cout << arr[i] << " ";
  } // output: 96 45 72
}