Using an enumeration as a template parameter

后端 未结 4 711
情书的邮戳
情书的邮戳 2020-12-13 09:29

I would like to use a template class to provide some common functionality to some child classes that are very similar. The only variation is the enumeration that each uses.

4条回答
  •  暖寄归人
    2020-12-13 10:05

    You cannot move definition of template function to separate source file.

    There it wouldn't be compiled at all, because templates can't be compiled, only template instances can.

    Your code in separate file isn't get compiled, that's why you actually have no definition for E_EnumerationBase::E_EnumerationBase(). That's why you get linker error.

    Just move all template code to your header.

提交回复
热议问题