I hava a class
class vlarray {
public:
    double *p;
    int size;
    vlarray(int n) {
        p = new double[n];
        size = n;
        for(int i = 0; i < n; i++)
            p[i] = 0.01*i;
    }
    ~vlarray() {
        cout << "destruction" << endl;
        delete [] p;
        size = 0;
    }
};
when I use in main
int main() {
    vlarray a(3);
    {
        vlarray b(3);
        b.p[0] = 10;
        for(int i = 0; i < 3; i++) {
            cout << *(b.p+i) << endl;
        }
        a = b;
    }    // the magic happens here deallocation of b
    for(int i = 0; i < 3; i++) {
        cout << *(a.p+i) << endl;
    return 0;
}
when b deallocated smth happens to a .. what is the problem, why that problem occurs and how to avoid such type of problems?
 
     
     
     
     
     
     
     
     
    