Member variable needs parameters for constructor
问题 I'm trying to include a member variable in the class I write, MyClass.h #include <SomeClass.h> Class MyClass{ public: MyClass(int par); SomeClass B; } MyClass.cpp #include "MyClass.h" #include "SomeClass.h" MyClass::MyClass(int par){ B=SomeClass(par); } However SomeClass takes variables for its constructor, so the above code yields no matching function for call to "SomeClass::SomeClass()" What should I do here? Update: Seems like member initializer list is the way to go, but how if I want to