首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

新手,求解答~解决思路

2012-03-27 
新手,求解答~~#include iostreamusing namespace stdclass A{public:A(){static int i1//coutcons

新手,求解答~~
#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

热点排行