初級 › error: no match for 'operator>>' の原因と直し方 › パターン2
error: no match for 'operator>>' の原因と直し方
std::cout に >> を使ったり、std::cin に << を使ったりと、ストリーム演算子の向きを取り違えたときに出るエラーです。
1 #include <iostream> 2 int main() { 3 std::cout __ "result: " << 42 << std::endl; ^ 4 return 0; 5 }
main.cpp:3:15: error: no match for 'operator>>' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'const char [9]')
空欄を埋めてコンパイル・実行を通す
coutの直後に置く演算子はすべて<<でなければなりません。1箇所でも>>にすると、そこでストリーム演算子の連鎖が壊れます。
次の問題