private access error

class x
{
private:
int a[n];
public:
int *ptr;
.
.
.

when i tried initiliaze a[n] in constructor like ptr=a and use "a" in some function
still i get private access error how can i deal with this situtaion???

and another question is that how can i free a[n] using destructor and delete????
when i tried i get a lot of memory errors

Need to see code.

a should not be deleted since it was never newed.
class x
{
private:
int a[n];
public:
int *ptr;


these are not real code only example i allocated memory for "a" in constuructor but when i tried to free it in destructor like
delete [] a; i get a lot of memory errors
You couldn't have allocated memory for a in your constructor because a is not a pointer.

If you didn't allocate with new, you shouldn't use delete.

If you need more help you'll have to show us more code (how are you allocating memory, how are you freeing it, etc)
sorry i didnt allocate memory for a i confused it another one....

anyway

question is that

how can i free a[n] with using destructor?

Topic archived. No new replies allowed.