I have a class and i keep getting some error from the destructor.
This is the clas:

```
#pragma once
class Number
{
    int bas;
    char* val;
public:
    Number(const char* value, int base); 
    Number(const Number& x);
    ~Number();
    void SwitchBase(int newBase);
    void Print();
    int  GetDigitsCount();
    int  GetBase(); 
};

```

This is the cpp file:

```
#include "Number.h"
#include <iostream>
Number::Number(const char* value, int base)
{
    int a = -1;
    do
    {
        a++;
    } while (value[a] != '\0');
    val = new char[a + 1];
    for (int i = 0; i <= a; i++)
        val[i] = value[i];
    bas = base;
}

Number::Number(const Number& x)
{
    int a = -1;
    bas = x.bas;
    do
    {
        a++;
    } while (x.val[a] != '\0');
    delete[]val;
    val = new char[a + 1];
    int i;
    for (i = 0; i <= a; i++)
        val[i] = x.val[i];
}
Number::~Number()
{
    delete[]val;
}
void Number::Print()
{
    std::cout << "Numarul este: " << val<< std::endl << "Baza este: " << bas<<std::endl;
}
int Number:: GetDigitsCount()
{
    int l = 0;
    do
    {
        l++;
    } while (val[l] != '\0');
    return l;
}

```

This is the main:

```
int main()
{
    Number x("123", 10),y("111",10),z("0",10);
    z = y;
    z.Print();
}

```

I keep getting this error:
Invalid address specified to RtlValidateHeap( 010C0000, 010C8DD8 )
If i do this change in main it works properly but it is not really what I want...

```
int main()
{
    Number x("123", 10),y("111",10);
    Number z = y;
    z.Print();
}

```

How can I solve this? I can't figure it out...