class Base {
public:
virtual void load() = 0;
};
template<typename T>
class CustomConfig : public Base {
public:
const T& getData() { return data; }
T data;
};
template<>
class CustomConfig<std::set<uint32_t>> {
public:
virtual void load() {
this->data = {4, 5, 6};
}
};
I don't know why I got the error:
class CustomConfig<std::set<unsigned int> >' has no member named 'data'
REAL CASE
In fact, I got such an issue: I need a virtual function, but it's return type is not unique, it may be a std::set, a std::vector, std::list or some other types. Then I was thinking the template technique might help. That's why I defined the class template<typename T> class CustomConfig.
I hope this was not a serious XY problem... Obviously I misunderstood how template class works.