new 在堆内存中开辟内存空间,delete 释放开辟的内存空间
int main(){ int * p = new int(10); cout << *p << endl; delete p; cout << *p << endl; int * arr = new int[10]; for(int i=0; i< 10 ; i++){ arr[i] = i +10; } for(int i=0; i< 10 ; i++){ cout << arr[i] << endl; } delete [] arr; cout << arr[0] << endl; return 0; }