Why can’t we initialize members inside a structure?
Why can’t we initialize members inside a structure ? example: struct s { int i = 10; }; Answer If you want to initialize non-static members in struct declaration: In C++ (not C), structs are almost synonymous to classes and can have members initialized in the constructor. struct s { int i; s(): i(10) { … Read more