First off, I'm new to C++ and very accustomed to working in MatLAB. My code will probably want to make seasoned C++ users shoot me in the face, but it looks like this:
EDIT: I have heavily edited my code snippet. The following is a cleaned up, generalized example of what I'm trying to accomplish.
int main()
{
int t = 0;
vector<int> Pad_Ref_Vec; //initialize vector. Required size unknown
for (int n = 0; n <= 10; n++)
{
if (t == 0)
{
vector<int> Pad_Ref_Vec(100); //at this point in the code, i know the size i need this vector to be
for (int i = 0; i < 100; i++)
{
Pad_Ref_Vec[i] = i;
}
}
else
{
//do some operation using the values of Pad_Ref_Vec created in the above
//if statement
}
t++;
}
return 0;
}
If I do this, the vector Pad_Ref_Vec does not read [0 1 2 3 4 5 ... ... ] after the if statement, but goes back to its previous form (after the first initialization before the for
loop) which is just a vector of size 0
I'm finding it hard to believe that something so simple is turning out to be such a hassle. Thanks in advance for any constructive tips.