I have this vector of pointers to vector:
std::vector<std::shared_ptr<std::vector<int>>> vec;
I want to initialize the first pointer to be a pointer to an empty vector. I tried this:
vec.push_back(nullptr);
Then I want to push_back some value to the vector where the nullptr points. I did this:
vec[0]->push_back(x);
Which I know is wrong, it ends up in segfault. I tried to do something with make_shared() instead of nullptr, but I still can't figure out how to achieve what I mentioned. Could anyone help me fix this example?