This is C++. I have the following program:
#include <iostream>
using namespace std;
template <typename T>
class Base {
public:
T t;
void use() {cout << "base" << endl;};
};
template <typename T>
class Derived: public Base<T> {
using Base<T>::use;
public:
T x;
void print() { use(); };
};
using namespace std;
int main() {
Derived<float> *s = new Derived<float>();
s->Base<float>::use(); // this is okay
s->use(); // compiler complaints that "void Base<T>::use() is inaccessible"
s->print(); // this is okay
return 0;
}
Base::use() does not use the template typename T. According to Why do I have to access template base class members through the this pointer?, I used 'using Base::use' in Derived so I can refer to it as 'use' in Derived::print(). However, I cannot call use() via a pointer to Derived anymore. What would cause this?