【发布时间】:2021-12-17 17:32:36
【问题描述】:
#include<iostream>
using namespace std;
int main(){
cout<"Yes";
}
它可以编译,但是当它运行时,它什么也不做。这是其他地方的编译错误。 编译器是 gcc 4.9.2
对比
#include<iostream>
using namespace std;
int main(){
cout<<"Yes";
}
它缺少一个“
我预计它是一个编译错误,就像变量一样,像这样:
> 6 6 C:\Users\Denny\Desktop\Codes\compileerror.cpp [Error] no match for
> 'operator<' (operand types are 'std::ostream {aka
> std::basic_ostream<char>}' and 'int')
下面的代码也会发生这种情况。
#include<iostream>
using namespace std;
int main(){
cin>"Yes";
}
编辑: 同样的事情发生在
#include<iostream>
int main(){
std::cout<"Yes";
}
另外,我启用了编译器警告,但没有。
【问题讨论】:
-
你的意思是写
cout << "Yes";? -
有很多拼写错误导致语法正确。
-
GCC 4.9.2 已经过时了,你可能会尝试一个更新的——尽管想知道为什么
std::ostream和指针有一个 less 运算符(如果它编译,如你所说)......跨度> -
为什么这个问题被关闭了?在 C++11 之前,basic_ios 有
operator void*()所以 cout 被强制转换为指针,然后 -
如果您将文本作为文本而不是链接或图像发布,我会考虑投票重新开放。