omo inicializar estruturas aninhadas em C +
Criei algumas estruturas diferentes em um programa. Agora tenho uma estrutura com estruturas aninhadas, mas não consigo descobrir como inicializá-las corretamente. As estruturas estão listadas abaixo.
/***POINT STRUCTURE***/
struct Point{
float x; //x coord of point
float y; //y coord of point
};
/***Bounding Box STRUCTURE***/
struct BoundingBox{
Point ymax, ymin, xmax, xmin;
};
/***PLAYER STRUCTURE***/
struct Player{
vector<float> x; //players xcoords
vector<float> y; //players ycoords
BoundingBox box;
float red,green,blue; //red, green, blue colour values
float r_leg, l_leg; //velocity of players right and left legs
int poly[3]; //number of points per polygon (3 polygons)
bool up,down;
};
Tento intializar uma estrutura Player criada recentemente, chamada playe
//Creates player, usings vectors copy and iterator constructors
Player player = {
vector<float>(xcords,xcords + (sizeof(xcords) / sizeof(float)) ), //xcords of player
vector<float>(ycords,ycords + (sizeof(ycords) / sizeof(float)) ), //ycoords of playe
box.ymax = 5; //create bounding box
box.ymin = 1;
box.xmax = 5;
box.xmin = 1;
1,1,1, //red, green, blue
0.0f,0.0f, //r_leg,l_leg
{4,4,4}, //number points per polygon
true,false}; //up, down
Isso causa vários erros diferentes, relacionados à caixa. A indicação da caixa não tem identificador claro e falta de estrutura ou sintaxe antes de '.'.
Eu tentei apenas criar uma estrutura do Player e inicializar seus membros da seguinte maneira:
Player bob;
bob.r_leg = 1;
Mas isso causa mais erros, pois o compilador acha que bob não tem identificador ou está faltando alguma sintax
Pesquisei no Google o problema, mas não encontrei nenhum artigo mostrando como inicializar muitos membros diferentes de estruturas aninhadas na estrutura (principal). Qualquer ajuda sobre este assunto seria muito apreciada :-) !!!