error in class destructor

I just started my container class and already I'm having issues:

class Container

    string* BasePointer; // The starting pointer.
    unsigned int Capacity; // The number of values the container can hold.


    Container() // Default constructor.
        Capacity = 1;
        BasePointer = new string[Capacity];

    ~Container() // Destructor.
        delete BasePointer; // Delete the container to prevent memory leaking.

I get the error Container Classes(26467) malloc: *** error for object 0x100100088: pointer being freed was not allocated. What am I doing incorrectly?


The XXX ptr = new XXX[size] should be matched with array version delete [] ptr, not just regular delete.

Read about free store management in C++, and as James reminds us - follow the rule of three in cases like this.

Need Your Help

Core Data Model For Test Taking iOS App

ios objective-c core-data database-design database-schema

I'm building an iOS app for test taking and I want to be sure of my model before proceeding.