新手,求解答~~
#include <iostream>
using namespace std;
class A
{
public:
A()
{
static int i=1;
//cout<<"construct "<<i<<endl;
printf("%d %d \n",i++,++i);
}
~A()
{
static int i=2;//////测试出来好像应该是作用域覆盖
//cout<<"destruct "<<i<<endl;
printf("%d %d\n",i++,++i);
}
};
int main()
{
A *pA=new A;
delete pA;
}
[解决办法]
What's the value of i++ + i++?
It's undefined. Basically, in C and C++, if you read a variable twice in an expression where you also write it, the result is undefined. Don't do that.
i see.
[解决办法]
去看这篇文章
http://blog.csdn.net/qqianqq/article/details/6733681