Hello guys
i'm having a trouble with my vectors, first time i get such problem, whenever i used VectorName->push_back ( something ); all the members in the vector becomes same as the new element,here's the code:
struct Array8x8
{
int field[8][8];
};
struct AIMOVETEMPLATE
{
//..
vector<Array8x8*> MoveField;
//..
};
//..
//...
AIMOVETEMPLATE *amt = new AIMOVETEMPLATE;
Array8x8 fld8x8;
fld8x8.field[0][0] = 2;
fld8x8.field[0][1] = 2;
amt->MoveField.push_back ( &fld8x8 );
fld8x8.field[0][0] = 1;
fld8x8.field[0][1] = 1;
amt->MoveField.push_back ( &fld8x8 );
after this code, both amt->MoveField members have the second value, all elements keeps getting same data as the last element, why is that? did i define vectors in a wrong way or something? im pretty sure i did the same thing with one of my programs and it worked well