0

我发现这个编译错误很奇怪。错误 C2678:二进制“>>”:未找到采用“std::istream”类型的左操作数的运算符(或没有可接受的转换)我在 MVC++ Express 2010 下编译,这是代码:

该错误表明它来自第 8 行。

1    int m;
2    vector <string> grid;
3
4    cin >> m;
5
6    for(int i=0; i<m; i++) {
7       string s; 
8   cin >> s;
9        grid.push_back(s);
10    }
4

3 回答 3

5

你需要#include <string>。另外,如果您没有它们,请添加#include <iostream>and #include <vector>

于 2013-09-30T13:16:41.147 回答
1

你需要#include<string>并且#include<iostream>

于 2013-09-30T13:17:14.443 回答
0

就我而言,当我这样做时出现了错误:

volatile int a;
std::cin << a;

显然,<< 运算符不会为 volatile int 重载,因此删除 'volatile' 是解决方案。

于 2018-04-17T08:59:23.223 回答