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. Template specialization with static data member

Template specialization with static data member

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
1 Posts 1 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.
  • T Offline
    T Offline
    tuxyboy
    wrote on last edited by
    #1

    I get LNK2005 errors with the static CRuntimeClass datamember of the specialized template Why? I simplified the classes to highlight the problem. TXBase contains special algorithms and also the CRuntimeClass functions and static classTXBase to make RUNTIME_CLASS things work. //////////////////////////////////////////////////////////// // TXView template //////////////////////////////////////////////////////////// #undef CLASS_NAME #define CLASS_NAME classTXView_##BASE template < class BASE > class TXView : public TXBase < BASE > { public: TXView(UINT nIDTemplate = 0); virtual CRuntimeClass* GetRuntimeClass(); static const CRuntimeClass CLASS_NAME; }; template < class BASE > TXView< BASE >::TXView(UINT nIDTemplate /*= 0*/) : TXBase< BASE >::TXBase(nIDTemplate) { } template < class BASE > const CRuntimeClass TXView::CLASS_NAME = { "TXView", sizeof(class TXView), 0xFFFF, TXView::CreateObject, TXView::_GetBaseClass, 0 }; template < class BASE > CRuntimeClass* TXView::GetRuntimeClass() { return (CRuntimeClass*)&TXView::CLASS_NAME; } ///////////////////////////////////////////////////////////////// // Specialized template for FormView ///////////////////////////////////////////////////////////////// #undef CLASS_NAME #define CLASS_NAME classTXView_##CFormView template <> class TXView < CFormView > : public TXBase < CFormView > { public: inline TXView(UINT nIDTemplate = 0); inline virtual CRuntimeClass* GetRuntimeClass(); static const CRuntimeClass CLASS_NAME; }; template <> inline TXView< CFormView >::TXView(UINT nIDTemplate /*= 0*/) : TXBase< CFormView >(nIDTemplate) { } template <> const CRuntimeClass TXView::CLASS_NAME = { "TXView", sizeof(TXView), 0xFFFF, TXView::CreateObject, &TXView::_GetBaseClass, 0 }; template <> inline CRuntimeClass* TXView::GetRuntimeClass() { return (CRuntimeClass*)&TXView::CLASS_NAME; } Thanks if you can help!

    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