使用xcode运行c ++程序时出现以下错误。除了自定义析构函数之外,该程序工作正常,以释放对象“workforce”中动态分配的内存。使用Dev c ++运行相同的代码时不会发生错误。我更喜欢xcode作为IDE。也许有一个需要调整的编译器设置?
A4Q1(94887)malloc: * 对象0x100100a38错误:未释放指针
workforce::workforce(int n) // set size = n and allocate an array of employees
{
size = n;
list = new employee [n]; //allocate sufficient memory for n employees
}
// big 3 prototypes here
workforce::~workforce(void)
{
delete [] list;
//cout << "Destroying workforce"<<endl;
}