⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 reallocate.cpp

📁 1. 系统概述: 图书馆管理系统是运行于Windows系统下的应用软件
💻 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 + -