有人可以解释这段代码在编译时不会出错吗?
int main()
{
// why doesn't the following line give a type mismatch error??/
return "success!";
}
答案 0 :(得分:9)
由于三字符??/
被\
取代,意味着返回已被注释掉。您的代码等同于
int main()
{
// why doesn't the following line give a type mismatch error\
return "success!";
}
与
相同int main()
{
// why doesn't the following line give a type mismatch error return "success!";
}
另请注意,如果return
中没有main
语句,则会隐式return 0;
,因此代码已明确定义。