I want to initialize a struct within a default class initializer list. For example, if I have a class like like this:
class Foo
{
private:
int x;
int y;
int z;
somestruct p;
public:
Foo(): x(1), y(2), z(3)
{
// other stuff
}
};
So, I can clearly initialize primitive types this way – how do I initialize a struct, for example the somestruct p parameter? Are there any limitations on the design of p if initialized this way?
In the code below,
m_strctis a member ofMyClass, and is initialized by the default constructor.