#include <iostream>
using namespace std;
class a
{
public:
a(int s,int ss)
{
b = s;
c = new int(ss);
}
~a()
{
if (c != NULL)
{
delete c;
}
c = NULL;
}
a(const a &ww)
{
b = ww.b;
c = new int(*ww.c);
}
a &operator++()
{
++b;
++*c;
return *this;
}
a operator++(int)
{
a www = *this;
b++;
*c++;
return www;
}
int b;
int *c;
};
ostream &operator<<(ostream &cout,a ww)
{
cout << ww.b << *ww.c;
return cout;
}
int main()
{
a s(10,180);
a sss(10,200);
s++;
sss++;
cout << s << " " << sss << endl;
return 0;
}
在后置递增重载中*c++有什么错误吗为什么运行就说断点没操作权限了
我知道我写了一个析构函数这个对象结束*c放在了堆区也被释放掉了但是为什么前置递增能正常运行