Yes, it is possible. However, do note that vector<vector<pair<int,int>>> foo;
the foo is empty. You could push_pack one or more vector<pair<int,int>> "rows" into it (and fill each row separately).
class Test{
public:
vector<vector<pair<int, int>>> Objects;
};
vector<vector<Test>> foo;
That is a bit scary, because it is almost the same as: vector<vector<vector<vector<pair<int, int>>>>> foo;
A 4D array of pairs.
How do i then insert a pair?
1 2 3 4 5 6 7 8 9 10 11
size_t rows = ...
size_t cols = ...
vector<vector<pair<int,int>>> bar( rows, vector<pair<int,int>>( cols ) );
// the bar does already have rows*cols pairs. One has to simply change their values.
for ( size_t row = 0; row < bar.size(); ++row {
for ( size_t col = 0; col < bar[row].size(); ++col ) {
// some "real" data
bar[row][col].first = 42 + row;
bar[row][col].second = col - 7;
}
}
objects_vector(temp); // gives me an error message saying this constructor doesn't exist..
One element (value_type) in your objects_vector is a vector<Test>. The temp is a vector<vector<pair<int,int>>>. Its value_type is vector<pair<int,int>>.