Forward Declaration of Template Class (Visitor Design Pattern)
问题 I am trying to forward declare a templated class A<T> for use in a class Visitor . It would suffice for my purposes to declare the int instance A<int> of the class A . I have tried two approaches but both give different errors, and I don't know how to proceed. Here is a MWE of my error: namespace visitor{ class Visitor{ public: virtual void visit(nsp::A<int>*) = 0; }; } namespace nsp{ template <class T> class A{ A(); T t_attribute; void accept(visitor::Visitor*); }; void A<int>::accept