I have an abstract (templated) class that I want to have its own return type InferenceData.
template <typename StateType>
class Model {
public:
struct InferenceData;
virtual InferenceData inference () = 0;
};
Now below is an attempt to derive from it
template <typename StateType>
class MonteCarlo : public Model<StateType> {
public:
// struct InferenceData {};
typename MonteCarlo::InferenceData inference () {
typename MonteCarlo::InferenceData x;
return x;
}
};
This works, but only because the definition of MonteCarlo::InferenceData is commented out. If it is not commented, I get invalid covariant return type error. I want each ModelDerivation<StateType>::InferenceData
to be its own type and have its own implementation as a struct. How do I achieve this?