+1  A: 

Appears to work fine in Visual C++ 2008. I've added some dummy definitions for the types you mentioned but gave no source for. The rest is exactly as you put it. Then a main function to force BarFunc to be instantiated and called.

#include <iostream>

class streamable {};
std::ostream &operator<<(std::ostream &os, streamable &s) { return os; }

class foo_arg_t : public streamable {};
class a_arg_t : public streamable {};
class b_arg_t : public streamable  {};

template <class T>
class Foo {

public:
 Foo (const foo_arg_t foo_arg) : _foo_arg(foo_arg)
 {
  /* do something for foo */
 }
 T Foo_T;        // either a TypeA or a TypeB - TBD
 foo_arg_t _foo_arg;
};

template <class T>
class Bar : public Foo<T> {
public:
 Bar (const foo_arg_t bar_arg, const a_arg_t a_arg)
 : Foo<T>(bar_arg)   // base-class initializer
 {

  Foo<T>::Foo_T = T(a_arg);
 }

 Bar (const foo_arg_t bar_arg, const b_arg_t b_arg)
 : Foo<T>(bar_arg)
 {
  Foo<T>::Foo_T = T(b_arg);
 }

 void BarFunc ();

};

template <class T>
void Bar<T>::BarFunc () {
 std::cout << _foo_arg << std::endl; 
 std::cout << Bar<T>::_foo_arg << std::endl;   
}

int main()
{
 Bar<a_arg_t> *b = new Bar<a_arg_t>(foo_arg_t(), a_arg_t());
 b->BarFunc();
}
Daniel Earwicker
g++ hands out a lot of errors regarding the definitions up top. However, the scope problem still remains with: "error: ‘_foo_arg’ was not declared in this scope," due to the first call to _foo_arg in the BarFunc() definition.
Shamster
Do you mean my dummy type declarations give you errors on gcc?
Daniel Earwicker
yes, the dummy types at top, but the scope error remains, as well.
Shamster
I believe g++ may be correct re: your original issue. The IBM compiler kicked up the same fuss, IIRC.
Daniel Earwicker
What are the error messages?
Daniel Earwicker
Sorry, I had added some test code - that was giving me the error. The code as you posted compiles if using the this->_foo_arg instead of _foo_arg in BarFunc().
Shamster
+3  A: 

You can use this-> make clear that you are referring to a member of the class:

void Bar<T>::BarFunc () {
    std::cout << this->_foo_arg << std::endl;
}

Alternatively you can also use "using" in the method:

void Bar<T>::BarFunc () {
    using Bar<T>::_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.

sth
The link to the Faq is _very_ useful: it also shows where this issue can unvisibly cause unwanted behaviour.
xtofl
Any idea *why* this is true? (the FAQ does not answer this completely)
Catskul