KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have created a couple of different structures in a program. I now have a structure with nested structures however I cannot work out how to initialize them correctly. The structures are listed below. /***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; }; I then attempt to intialse a newly created Player struct called player. //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 This causes several different errors, concerning box. Stating the box has no clear identifier and missing struct or syntax before '.'. I then tried just to create a Player struct and initialise it's members as follows: Player bob; bob.r_leg = 1; But this causes more errors, as the compiler thinks bob has no identifier or is missing some syntax. I googled the problem but I did not find any articles showin
Tags (comma-separated)
Save Edits
Cancel