0

使用 xcode 运行 c++ 程序时出现以下错误。该程序工作正常,除了自定义析构函数释放对象“劳动力”中动态分配的内存。使用 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;
}
4

0 回答 0