“Undefined symbols” linker error with simple template class

后端 未结 3 825
遥遥无期
遥遥无期 2020-11-30 09:43

Been away from C++ for a few years and am getting a linker error from the following code:

Gene.h

#ifndef GENE_H_INCLUDED
#define GENE_H_INCLUDED

tem         


        
3条回答
  •  萌比男神i
    2020-11-30 10:32

    The template definition (the cpp file in your code) has to be included prior to instantiating a given template class, so you either have to include function definitions in the header, or #include the cpp file prior to using the class (or do explicit instantiations if you have a limited number of them).

提交回复
热议问题