我刚刚开始编写容器类,但已经遇到了问题:
class Container
{
private:
string* BasePointer; // The starting pointer.
unsigned int Capacity; // The number of values the container can hold.
public:
Container() // Default constructor.
{
Capacity = 1;
BasePointer = new string[Capacity];
}
~Container() // Destructor.
{
delete BasePointer; // Delete the container to prevent memory leaking.
}
};
我遇到了错误
Container Classes(26467) malloc: *** error for object 0x100100088: pointer being freed was not allocated
。请问我做错了什么?