See the following code example: #include <iostream> template <typename tn> class a{ protected: tn bar; public: a(tn bar){ this->bar=bar; } virtual tn getBar(){ return bar; } }; template <typename tn> class b : public a<tn>{ private: void add(tn baz); public: b(tn bar, tn baz) : a<tn>(bar) { add(baz); } }; template <typename tn> void b<tn>::add(tn baz){ bar+=baz; } int main(){ b<unsigned> test(7,5); std::cout << test.getBar() << std::endl; return 0; } This gives test.cpp: In member function `void b<tn>::add(tn)': test.cpp:30: error: `bar' undeclared (first use this function) test.cpp:30: error: (Each undeclared identifier is reported only once for each function it appears in.) As well as it's (in my and the opinion of ##c++) valid ANSI C++.
*** This bug has been marked as a duplicate of 15552 ***