我有以下代码:
#include <iostream>
#include <vector>
using namespace std;
vector<int> Reversed(const vector<int>& v){
//vector<int> v; //[Error] declaration of 'std::vector<int> v' shadows a parameter
int z; vector<int> copy; vector<int> working;
working = v;
z = working.size();
int i;
for (i = 0; i<=z; i++){
working[i] = working[z];
copy.push_back(working[i]);
}
return copy;
}
int main() {
vector<int> v;
cin >> v; /*[Error] no match for 'operator>>' (operand types are 'std::istream'
{aka 'std::basic_istream<char>'} and 'std::vector<int>')*/
cout << Reversed(v);
return 0;
}
请向我解释为什么我在第 18 行收到此错误:
运算符不匹配>>`
ps:const & i
是前置任务,我改不了。我只需要这个向量的颠倒副本。