I just started C++, how can I print only rows of 2d vector?
This is how I'm trying to do it but it fails.
std::vector<std::vector<int>> matrix2d{{1, 2, 3, 4},
{5, 6, 7, 8},
{9, 10, 11, 12}};
for (std::vector<int> i : matrix2d) {
std::cout << i << std::endl;
}
I get an error under std::cout <<.
Error nvalid operands to binary expression ('std::ostream' (aka 'basic_ostream<char>') and 'const std::vector<double>') candidate template ignored: deduced conflicting types for parameter '_CharT' ('char' vs. 'std::vector<double, std::allocator<double> >') candidate template ignored: could not match 'basic_string' against 'vector' candidate template ignored: could not match 'const _CharT *' against 'std::vector<double>' candidate template ignored: requirement '__and_<std::__not_<std::is_lvalue_reference<std::basic_ostream<char, std::char_traits<char> > &> >, std::__is_convertible_to_basic_ostream<std::basic_ostream<char, std::char_traits<char> > &>, st...