Please consider the following types:
struct X
{
static std::string fullyQualifiedName();
};
struct A
{
template <class T> void foo()
{
return foo(T::fullyQualifiedName());
}
protected:
virtual void foo(const std::string& name) = 0;
};
struct B : public A
{
protected:
void foo(const std::string& name);
};
I have a pointer to instance B, I am trying to call the template version fooas follows:
b->foo< X >();
The compiler complains: "X": illegal use of this type as an expression.
On the other hand, this code works fine:
A* a = b;
a->foo< X >();
Hence my question.
source
share