How to initialize an inner structure inside the outer structure?
struct TOuter
{
struct TInner
{
bool b1, b2;
TInner () : b1 (false), b2(false) {}
};
bool b3;
TOuter (): TOuter::TInner(), b3(true) {} // Error
};
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In this case, you have no object of the
TInnerstruct, so there’s no need to initialize anything.Other than that, it’s just the same as with any other class/struct type: