Access the inner class type of a template [duplicate]

  abstract, c++, inheritance, templates

I’m new to C++, I want to make a simple abstraction where I pass an implementation of A (and its sub-class B) to C.

But I’m getting the error T::B does not name a type

class A {
public:
   class B {
   public:
      virtual void func1();
   };
};
template<typename T, typename std::enable_if<std::is_base_of<A, T>::value>::type* = nullptr>
class C {
   /* ERROR : T::B is not a type */
   void func2(T::B b) {
      b.func1();
   }
   /* ERROR : TB is not a type */
   typename T::B TB;
   void func2(TB b) {
      b.func1();
   }
};

Source: Windows Questions C++

LEAVE A COMMENT