Reputation: 190809
I have this C++ code to generate "primary-expression before '.' token' error with g++ compiler. It compiles OK with cl (MSVC) compiler.
template<typename T>
class A : public std::auto_ptr<T>
{
typedef std::auto_ptr<T> Super;
public:
A() : Super() { }
A(T* t) : Super(t) { }
A(AP<T>& o) : Super(o) { }
operator bool() { return !!Super.get(); } <--- error!
};
What's wrong with this code?
Upvotes: 3
Views: 299
Reputation: 355069
Super
is a type. If you want to call the base class function, you can do so via this
:
this->get();
Note that this->
is only required here because get()
is a member function of a dependent base class; that is, a base class that is dependent upon the template parameter T
. For more information, consult the Parashift C++ FAQ article, "Why am I getting errors when my template-derived-class uses a member it inherits from its template-base-class?"
Upvotes: 8