   Very Nested structs and how to handle them?
  I'm not talking about simple nested structs. :)I'm talking about very nested structs.For example:int main(){struct Struct1{struct Struct2{struct Struct3{struct Struct4{//etc...};};};};return 0;}I wanted to know:1. How should I easily manage these highly nested structs? (SDL_Rect and Camera settings...) 2. Is the only way to go ahead and use these is the declarations of variables that were within the structs?Like, if there's an int variable 'a' in one of the structs, we do: Struct1.Struct2.Struct3...StructN.a = 1;
  I think you may be confusing "nested structs" with just plain ol' member variables.  Do mean this?// Struct1 has a Struct2 (named "a") which has a Struct3 (named "b") which has an integer (named "c")// Essentially, sizeof(Struct1)==sizeof(int)struct Struct1 {struct Struct2 {struct Struct3 {int c;};Struct3 b;};Struct2 a;};int main() {Struct1 foo;foo.a.b.c = 1;Struct1::Struct2 bar;bar.b.c = 2;Strcut1::Struct2::Struct3 baz;baz.c = 3;}Or this?struct Vector {float x, y, z;};struct Struct1 {char buf[10];int data;};struct Struct2 {Struct1 asdf;Vector jkl;};struct Struct3 {Struct1 a;Struct2 b;};int main() {Struct3 foo;foo.b.data = 5;foo.a.asdf.data = 6;};Quote:Original post by tom_mai78101Like, if there's an int variable 'a' in one of the structs, we do: Struct1.Struct2.Struct3...StructN.a = 1;No, because as your code Shows, Struct1, Struct2 etc are types, not variables.I don't think you're going to get a good answer unless you post the real class definition(s).   ;  With the code you posted (with an added variable) this is how you create an instance of Struct4. Note that sizeof(Struct1), sizeof(Struct2) and sizeof(Struct3) are all 0 - they have no data in them. You could declare them as namespaces instead of structs and get the same result.struct Struct1{struct Struct2{struct Struct3{struct Struct4{int foo;};};};};Struct1::Struct2::Struct3::Struct4 s4 = {0};int bar = s4.foo;;  Guess I might've mistaken something else with nested structs. :P;  Moved to For Beginners.   