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 use an array of SomeClass
objects? So MyClass.h becomes:
#include <SomeClass.h>
Class MyClass{
public:
MyClass(int par);
SomeClass B[2];
}