1

I am having trouble with a compilation error as shown below:

C:\Users........................(35): note: while compiling class template member function 'void cs140::RenderVisitors::visit(cs140::Background &)'

Can anyone help to enlighten me on this? I've been stuck for a while now, searching the internet for sources that resemble this error, but they are all unrelated cases. Thank you. Do note: the code below isn't compilable.

Header file

namespace cs140
{
    template <typename T>
    class Background
    {
    };
    template<typename T>
    class RenderVisitors 
    {
       public:
       void visit(Background<T>& background);

       private:

     };

   }

HPP file

namespace cs140
{
    template<typename T>
    void RenderVisitors<T>::visit(Background<T>& background)
    {

    }
}
  • 3
    Seems like there should be more to that error. What is a HPP file and how is it different from the header file? Is it being included or compiled? Perhaps this might shed some light: https://stackoverflow.com/questions/495021/why-can-templates-only-be-implemented-in-the-header-file – Retired Ninja Jul 01 '20 at 04:38
  • 1
    [Cannot duplicate](http://coliru.stacked-crooked.com/a/1c27f608b864ad91). – PaulMcKenzie Jul 01 '20 at 04:39
  • Please post the whole error message. – schteppe Jul 02 '20 at 10:39

0 Answers0