CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2017
    Posts
    50

    [RESOLVED] Why we cannot put class template member function definition in cpp file.

    If I class template member function definition in cpp file,I got bunch of linker error.But it works fine if the definition is in the header file along with the class template.Why is it like that?.Did I miss something.

  2. #2
    Join Date
    Feb 2017
    Posts
    677

    Re: Why we cannot put class template member function definition in cpp file.

    Quote Originally Posted by noobofcpp View Post
    Why is it like that?.Did I miss something
    By putting the whole template definition in an include file you are using the inclusion model. See here for an explanation,

    https://docs.microsoft.com/en-us/cpp...-cpp-templates
    Last edited by wolle; January 1st, 2018 at 11:27 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured