标签:c++动态内存分配与释放
一般变量的分配与释放
#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; }
本文出自 “桑海田 博客专栏” 博客,请务必保留此出处http://10602803.blog.51cto.com/10592803/1683040
标签:c++动态内存分配与释放
原文地址:http://10602803.blog.51cto.com/10592803/1683040