Hello this block of code is not compiling for some reason and for the life of my I can't figure it out. It gives me an error when it calls the destructor could someone tell me why please
The error is:
Exception thrown test.exe has triggered a breakpoint"
#include <iostream>
using namespace std;
class X {
public:
X(int i)
{
p = new (int);
*p = i;
}
~X() { delete p; }
int* p;
};
int main()
{
X x1(1);
X x2(2);
x2 = x1;
}