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. Function template

Function template

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++question
2 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
    RalfPeter
    wrote on last edited by
    #1

    I keep getting the following error upon linking: "error LNK2001: unresolved external symbol "public: class CString __thiscall CMyDoc::FKeyReset(int)" This happens when I try to instantiate a function template. The code snippets are below. Does any one spot an obvious problem in it? Thanks, Ralf. MyDoc.h: template CString FKeyReset(T RecSet); MyDoc.cpp template CString FKeyReset(T RecSet) { CString str; if(T > 0) str.Format("message 1"); else str.Format("message 2"); return str; } Elsewhere outside MyDoc: CMyDoc *pMyDoc = (CFisheriesDoc *) //pointer to MyDoc ((CFrameWnd*) AfxGetApp()->m_pMainWnd)->GetActiveDocument(); CString szAstr; int i = 2; szAstr = pMyDoc ->FKeyReset(i); //offending line ralf.riedel@usm.edu

    J 1 Reply Last reply
    0
    • R RalfPeter

      I keep getting the following error upon linking: "error LNK2001: unresolved external symbol "public: class CString __thiscall CMyDoc::FKeyReset(int)" This happens when I try to instantiate a function template. The code snippets are below. Does any one spot an obvious problem in it? Thanks, Ralf. MyDoc.h: template CString FKeyReset(T RecSet); MyDoc.cpp template CString FKeyReset(T RecSet) { CString str; if(T > 0) str.Format("message 1"); else str.Format("message 2"); return str; } Elsewhere outside MyDoc: CMyDoc *pMyDoc = (CFisheriesDoc *) //pointer to MyDoc ((CFrameWnd*) AfxGetApp()->m_pMainWnd)->GetActiveDocument(); CString szAstr; int i = 2; szAstr = pMyDoc ->FKeyReset(i); //offending line ralf.riedel@usm.edu

      J Offline
      J Offline
      John M Drescher
      wrote on last edited by
      #2

      Yes. You can not do that... This link should explain why: http://www.codeproject.com/cpp/templatesourceorg.asp?target=templates%7C%2Dasp[^] John

      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