D
danielhdez14142
Some time ago, I had a segment of code like
vector<vector<int> > example;
f(example);
and inside f, I defined vector<int>'s and used push_back to get them
inside example. I got a segmentation fault which I resolved by doing
vector<vector<int> > example;
example.push_back(vector<int>());
f(example);
I also remember that when debugging, I got the segmentation fault
right at the function call. I wonder why is it that I needed to do
this when the original code works if I had had a
vector<int> example
f(example)
and just pushed back integers inside f
I'm sorry because I don't have the actual code, this is a question
I'va had for a long time now and I simply don't have the code, but the
question is, can I pass vectors of vectors to a function without
initialising them and why if the answer is no?
Thanks
Daniel
vector<vector<int> > example;
f(example);
and inside f, I defined vector<int>'s and used push_back to get them
inside example. I got a segmentation fault which I resolved by doing
vector<vector<int> > example;
example.push_back(vector<int>());
f(example);
I also remember that when debugging, I got the segmentation fault
right at the function call. I wonder why is it that I needed to do
this when the original code works if I had had a
vector<int> example
f(example)
and just pushed back integers inside f
I'm sorry because I don't have the actual code, this is a question
I'va had for a long time now and I simply don't have the code, but the
question is, can I pass vectors of vectors to a function without
initialising them and why if the answer is no?
Thanks
Daniel