Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Ask a problem,about template:)

Ask a problem,about template:)

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rxgmoral
    wrote on last edited by
    #1

    Ask a problem,about template:) i write template class <<<<<<<<>>>>>>> #pragma once template class Tem { public: T rxg(T a); }; <<<<<<<<>>>>>>> #include "stdafx.h" #include "class.h" templateT Tem::rxg(T a) { return a; } <<<<<<<<<<>>>>>>>> #include "Class.h" ................................ Tem moral; int a=moral.rxg(10); Error: Test.obj : error LNK2019: unresolved external symbol "public: int __thiscall Tem::rxg(int)" (?rxg@?$Tem@H@@QAEHH@Z) referenced in function "public: void __thiscall CAboutDlg::OnBnClickedOk(void)" (?OnBnClickedOk@CAboutDlg@@QAEXXZ) thank:)

    F 1 Reply Last reply
    0
    • R rxgmoral

      Ask a problem,about template:) i write template class <<<<<<<<>>>>>>> #pragma once template class Tem { public: T rxg(T a); }; <<<<<<<<>>>>>>> #include "stdafx.h" #include "class.h" templateT Tem::rxg(T a) { return a; } <<<<<<<<<<>>>>>>>> #include "Class.h" ................................ Tem moral; int a=moral.rxg(10); Error: Test.obj : error LNK2019: unresolved external symbol "public: int __thiscall Tem::rxg(int)" (?rxg@?$Tem@H@@QAEHH@Z) referenced in function "public: void __thiscall CAboutDlg::OnBnClickedOk(void)" (?OnBnClickedOk@CAboutDlg@@QAEXXZ) thank:)

      F Offline
      F Offline
      FarPointer
      wrote on last edited by
      #2

      When you make a class template you need to globaly define the object type you are using in the class.h there are other ways to solve this also :- Look for class template instantiation. http://msdn2.microsoft.com/en-us/library/7y5ca42y.aspx[^]


      Regards, FarPointer Blog:FARPOINTER

      R 1 Reply Last reply
      0
      • F FarPointer

        When you make a class template you need to globaly define the object type you are using in the class.h there are other ways to solve this also :- Look for class template instantiation. http://msdn2.microsoft.com/en-us/library/7y5ca42y.aspx[^]


        Regards, FarPointer Blog:FARPOINTER

        R Offline
        R Offline
        rxgmoral
        wrote on last edited by
        #3

        thank you:)FarPointer

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups