📄 reallocate.cpp
字号:
#include<algorithm> // for std::copy
//类型指定!!
#include"Class/Reader.h"
typedef CReader ElemType;
bool reallocate(ElemType* &p, int &size, int addsize) //重新分配内存,成功true,失败false
{
size += addsize; //double the array''s size with each reallocation
ElemType * temp = new ElemType [size];
if (temp == NULL)return false;
std::copy(p, p+(size-addsize), temp);
delete [] p; // release original, smaller buffer
p=temp; // reassign p to the newly allocated buffer
return true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -