I overloaded the operator "=" to do something, but instead it goes and uses the constructor
class Date
{public:
int x;
public:
Date(int v1)
{
x = v1+1;
}
Date& operator=(Date& d)
{
x = x - 1;
}
public:
~Date() {};
};
int main()
{
Date d = 1;
cout << d.x;
//delete d;
return 0;
}
I was expecting to print 0 but instead it prints 2(uses the constructor). Why is that? Also why won't it let me delete d? it says it must be a pointer to a complete object type.