hi,
I've recently changed some code in my program from a multidimensional array to a vector, and I'm wondering if/how it's possible to initialise a vector array.
i.e.
vector<int> MyVector;
MyVector.push_back(int1,int2,int3,int4,int5);
old code:
Code:
//header
extern int LIST[][5];
//source
int LIST[][5] =
{
{24,3,2,5,16};
{24,2,5,16,3};
{n1,n2,n3,n4,n5};
};
//new code
Code:
//header
extern vector<int> LIST[5];
//source
void Create_List()
{
FillList(24,3,2,5,16);
FillList(24,2,5,16,3);
FillList(n1,n2,n3,n4,n5);
}
bool FillList(int i1, int i2, int i3, int i4, int i5)
{
LIST[0].push_back(i1);
LIST[1].push_back(i2);
LIST[2].push_back(i3);
LIST[3].push_back(i4);
LIST[4].push_back(i5);
return true;
}
At the moment, I use FillList() function to populate the vector. Just wondering if there's a better way to do this other than calling another function each time ?
Thanks!