Max*_*xpm 3 c++ pointers destructor memory-leaks class
我刚刚开始我的容器类,我已经遇到了问题:
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.
}
};
Run Code Online (Sandbox Code Playgroud)
我收到了错误Container Classes(26467) malloc: *** error for object 0x100100088: pointer being freed was not allocated
.我做错了什么?