Creating a template class object using a template constructor

前端 未结 3 1342
[愿得一人]
[愿得一人] 2021-02-09 18:45

I\'m having trouble creating a class object from a template class in which I need the constructor to also be a template and accept a parameter when the object is created. Howev

3条回答
  •  心在旅途
    2021-02-09 19:24

    You can force the instantiation of the template in another cpp file.

    BinaryTree;
    BinaryTree;
    BinaryTree;
    

    That way all the functions do not need to be in header files. Some people use the extension .inl for the files with the template implementations. So the .inl file is only needed when the instantiation doesn't already exist.

提交回复
热议问题