Reputation: 7421
Why does the following fail with error: 'a_' was not declared in this scope
in the context of Bar::get()
?
template <typename N>
class Foo
{
public:
Foo() { }
protected:
N a_;
};
template <typename N>
class Bar : public Foo<N>
{
public:
Bar() : Foo<N>() { }
N get() { return a_; }
};
Upvotes: 0
Views: 38
Reputation: 9237
You need to use the reference this->_a
N get() { return this->a_; }
Upvotes: 1