> I needed to use Fvect.resize(n); to fill the vector with default objects,
> In the for loop I use Fvect.push_back(form);
let's work with ints to simplify
say that `n' is 3, after the resize you have
{0, 0, 0}
then you enter the loop and put more numbers
{0, 0, 0, 54, 13, 42}
notice the size of the array, ¿are you going to do something with the 0?
then you call `menu1st()' again, so you resize the array and have
{0, 0, 0}
losing the numbers that you've put previously.
> "vector subscript is out of range"
1 2 3
|
vector<Form> Fvect;
cout << "EDIT A FORM" << endl;
cout << Fvect[1].Fname;
|
¿what were you expecting? you just created an empty vector two lines ago and now you are trying to access its second element.
Also, when a function ends it returns to its caller
1 2 3
|
foo():
bar() //when bar() ends program execution will continue
zoo() //and zoo() will be called
|
your calls to `menuMain()' from `menu1st()' and `menu2nd()' are wrong.
¿want to keep asking to select an operation? use a freaking loop.
> make it a global vector.
don't
pass it as an argument to the functions that may use of it.