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. Link error [modified]

Link error [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++data-structuresquestion
3 Posts 3 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
    ratprita
    wrote on last edited by
    #1

    when i changed the main function of a template class into a separate file, i have got a link error.Display is a function in the template class error LNK2001: unresolved external symbol "public: void __thiscall Gen_Queue<int>::Display(void)" (?Display@?$Gen_Queue@H@@QAEXXZ) What may be the problem? Anyone know the solution? I was coding a generic queue. i have made GenericQueue.cpp with functions Add(), delete() and display(). genericQueue.h have the variables and declaration of the functions. In another file GenericQueueMain.cpp i have written the function main() for the generic queue. I have made an object for the GenericQueue and tried to call the functions . Then i got the error-- error LNK2001: unresolved external symbol "public: void __thiscall Gen_Queue<int>::Display(void)" (?Display@?$Gen_Queue@H@@QAEXXZ)

    modified on Tuesday, October 13, 2009 6:23 AM

    CPalliniC C 2 Replies Last reply
    0
    • R ratprita

      when i changed the main function of a template class into a separate file, i have got a link error.Display is a function in the template class error LNK2001: unresolved external symbol "public: void __thiscall Gen_Queue<int>::Display(void)" (?Display@?$Gen_Queue@H@@QAEXXZ) What may be the problem? Anyone know the solution? I was coding a generic queue. i have made GenericQueue.cpp with functions Add(), delete() and display(). genericQueue.h have the variables and declaration of the functions. In another file GenericQueueMain.cpp i have written the function main() for the generic queue. I have made an object for the GenericQueue and tried to call the functions . Then i got the error-- error LNK2001: unresolved external symbol "public: void __thiscall Gen_Queue<int>::Display(void)" (?Display@?$Gen_Queue@H@@QAEXXZ)

      modified on Tuesday, October 13, 2009 6:23 AM

      CPalliniC Online
      CPalliniC Online
      CPallini
      wrote on last edited by
      #2

      What files? What is the 'main function' of a template file? What were the changes (i.e. There are chances you'll post the relevant code?)? :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      In testa che avete, signor di Ceprano?

      1 Reply Last reply
      0
      • R ratprita

        when i changed the main function of a template class into a separate file, i have got a link error.Display is a function in the template class error LNK2001: unresolved external symbol "public: void __thiscall Gen_Queue<int>::Display(void)" (?Display@?$Gen_Queue@H@@QAEXXZ) What may be the problem? Anyone know the solution? I was coding a generic queue. i have made GenericQueue.cpp with functions Add(), delete() and display(). genericQueue.h have the variables and declaration of the functions. In another file GenericQueueMain.cpp i have written the function main() for the generic queue. I have made an object for the GenericQueue and tried to call the functions . Then i got the error-- error LNK2001: unresolved external symbol "public: void __thiscall Gen_Queue<int>::Display(void)" (?Display@?$Gen_Queue@H@@QAEXXZ)

        modified on Tuesday, October 13, 2009 6:23 AM

        C Offline
        C Offline
        Cedric Moonen
        wrote on last edited by
        #3

        Your question is not really clear but I guess you are trying to move the definition of a template class from a header file to a cpp file. Am I right ? If that is the case, you can't do something like that. For a template class, the full definition of the class and functions has to be known when compiling, thus you have to include everything in the header file. One 'trick' to get around that problem is to move the definition in a .inl file (to differentiate from a standard cpp file) and include that file in your header file (at the bottom of the file).

        Cédric Moonen Software developer
        Charting control [v2.0] OpenGL game tutorial in C++

        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