前提・実現したいこと
c++で入力された配列をそのまま出力したいです
発生している問題・エラーメッセージ
エラーメッセージ
./Main.cpp: In function ‘int main()’:
./Main.cpp:6:7: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘std::vector<int>’)
6 | cin >> vec;
| ~~~ ^~ ~~~
| | |
| | std::vector<int>
| std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/9/sstream:38,
from /usr/include/c++/9/complex:45,
from /usr/include/c++/9/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
from ./Main.cpp:1:
/usr/include/c++/9/istream:120:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__istream_type& ()(std::basic_istream<_CharT, _Traits>::__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’
120 | operator>>(__istream_type& (__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/9/istream:120:36: note: no known conversion for argument 1 from ‘std::vector<int>’ to ‘std::basic_istream<char>::__istream_type& ()(std::basic_istream<char>::__istream_type&)’ {aka ‘std::basic_istream<char>& ()(std::basic_istream<char>&)’}
120 | operator>>(__istream_type& (__pf)(__istream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/9/istream:124:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__ios_type& ()(std::basic_istream<_CharT, _Traits>::__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>; std::basic_istream<_CharT, _Traits>::__ios_type = std::basic_ios<char>]’
124 | operator>>(__ios_type& (*__pf)(__ios_type&))...
該当のソースコード
c++
ソースコード
include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> vec(2);
cin >> vec;
cout << vec;
}
### その他
3 2
現在Atcorderのコードテストにて上記を入力しております.
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。