一般变量的分配与释放
#include<iostream> using namespace std; int main() { int *p = new int(4); *p = 10; cout << *p << endl; delete p; return 0; }
数组变量的分配与释放 #include
#include<iostream> using namespace std; int main() { char * p = new char[10]; p="hello"; cout << p << endl; delete [] p; return 0; }