C++ template inheritance does not see base class members -


please @ following code:

template<class mt> class classa { public:   int cnt; };  template<class mt> class classb : public classa<mt> { public:     void test() {      cnt++ ;    } }; 

when compiled, g++ gives error "cnt" not declared in scope.

if change cnt this->cnt, works. however, confused. can please explain why not work otherwise?

the reason cnt not dependent name (doesn't depent on template paremeter), rules of language state have qualify this-> or base::.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -