- How do I initialize a struct in a Class constructor list? [closed]
- class Foo
- {
- private:
- int x;
- int y;
- int z;
- somestruct p;
- public:
- Foo(): x(1), y(2), z(3)
- {
- // other stuff
- }
- };
- struct MyStruct
- {
- MyStruct(int i): // Constructor
- myData(i)
- { }
- int myData;
- };
- class MyClass
- {
- public:
- MyClass() : // default constructor
- m_strct(0)
- { }
- private:
- MyStruct m_strct;
- };