This question is a furtherance of the one asked in this thread.
Using the following class definitions:
template
class Foo {
public:
You can use this->
to make clear that you are referring to a member of the class:
void Bar::BarFunc () {
std::cout << this->_foo_arg << std::endl;
}
Alternatively you can also use "using
" in the method:
void Bar::BarFunc () {
using Bar::_foo_arg; // Might not work in g++, IIRC
std::cout << _foo_arg << std::endl;
}
This makes it clear to the compiler that the member name depends on the template parameters so that it searches for the definition of that name in the right places. For more information also see this entry in the C++ Faq Lite.