1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream> #include <iterator> #include <vector> int main() { std::vector<int> v{ 3, 1, 4 }; auto it = v.begin(); auto nx = std::next(it, 2); std::cout << *it << ' ' << *nx << '\n'; }
1 2 3
In function 'int main()': Line 7: error: a function-definition is not allowed here before '{' token compilation terminated due to -Wfatal-errors.