I have a problem with some of my constructors. Both subclasses need to get the same classes (no super class), that is why these classes should be initialized in the super class:
template<typename T, typename S>
class SuperClass {
protected:
OtherClass <T> const& _class1;
OtherOtherClass <T> const& _class2;
SuperClass() {
}
SuperClass(OtherClass<T> const& class1, OtherOtherClass<T> const& class2)
: _class1(class1), _class2(class2)
{
// Alternative I tried:
// this->_class1 = class1;
// this->_class2 = class2;
}
I tried to use it through:
template<typename T, typename S>
class SubClass1 : public SuperClass<T, S> {
private:
someFunc() {
return this->_class1.getSomething(); // as an example
}
public:
SubClass1(OtherClass<T> const& class1,
OtherOtherClass<T> const& class2)
: SuperClass(class1, class2)
{
// some definitions
}
}
After that this error shows up:
member initializer 'SuperClass' does not name a non-static data member or base class
I found some people with similar problems, but it did not lead me to the solution. For example: member initializer does not name a non-static data member or base class I did not see many difference there and tried to add an empty constructor like he did.