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

rest - Spring boot: Request method 'PUT' not supported -

php - Magento - Deleted Base url key -

symfony - imagine_filter() not generating the correct url in LiipImagineBundle -