开发者

vector of vector

开发者 https://www.devze.com 2023-01-10 23:09 出处:网络
I have the following code开发者_StackOverflow fragment #include <iostream> #include <ostream>

I have the following code开发者_StackOverflow fragment

#include <iostream>
#include <ostream>
#include <vector>
using namespace std;

int main() {
    vector<vector<int>>v;
    return 0;  
}

v.push_back(11) does not work what is correct?


#include <iostream>
#include <ostream>
#include <vector>
using namespace std;

int main() {
    vector<vector<int> >v;
    vector<int> a;
    a.push_back(11);
    v.push_back(a);
    return 0;  
}

I think this should work right :)


vector<vector<int>>v;

needs to be

vector<vector<int> >v;

The consecutive >> acts as the actual >> operator.

0

精彩评论

暂无评论...
验证码 换一张
取 消