面试例题1:which of the following statements describe the results of executing the code snippet below in c++?
int i=1;
void main()
{
int i=i;
}
The i within main will an undefined value.
#include <iostream>
using namespace std;
int i=1;
void main(){
int i=i;
//编译成功,运行没出结果
}
在c++中合法
例题2.what does the following problem print?
#include <iostream>
using namespace std;
int main(){
int x=2,y,z;
x*=(y=z=5);
cout<<x<<endl;
z=3;
x==(y=z);
return 0;
}
x=10, x==(y==z) 不管相等不相等,x并未发生变化,仍然是10
x=(y&z)的意思是说首先使y和z按位与,
x=(y&&z)首先使y和z按位与,与运算是指如果y为真,z为真,返回1