初級 › error: no match for 'operator>>' の原因と直し方 › パターン3
error: no match for 'operator>>' の原因と直し方
std::cout に >> を使ったり、std::cin に << を使ったりと、ストリーム演算子の向きを取り違えたときに出るエラーです。
1 #include <iostream> 2 int main() { 3 int age; 4 std::cin __ age; ^ 5 std::cout << age << std::endl; 6 return 0; 7 }
main.cpp:4:14: error: no match for 'operator<<' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'int')
空欄を埋めてコンパイル・実行を通す
std::cinは入力用のストリームで、値を受け取る向きの>>しか受け付けません。<<はstd::coutのための演算子です。
次の問題