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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
M

Martin Vladic

@Martin Vladic
About
Posts
4
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Template Question
    M Martin Vladic

    I found out why some chars was stripped from my message and how to send it correctly. So, here it is, again: It is invalid C++. Your idea written correctly looks like this: template class TType { public: CString GetAsString() { CString sValue; sValue.Format(GetFormat(), m_tValue); return sValue; } protected: T m_tValue; }; template <class T> CString GetFormat(); template <> CString GetFormat<int>() { return "%d"; } template <> CString GetFormat<float>() { return "%.4f"; } Unfortunately, this doesn't work on VC++ 6.0 (GetFormat<int> is called even for float's). Try this: template <class T> class TType { public: TType(const T& value) : m_tValue(value) { } CString GetAsString() { CString sValue; sValue.Format(TypeHelper::GetFormat(), m_tValue); return sValue; } protected: T m_tValue; }; template <class T> class TypeHelper; template <> class TypeHelper<int> { public: static CString GetFormat() { return "%d"; } }; template <> class TypeHelper<float> { public: static CString GetFormat() { return "%.4f"; } }; -- Martin

    C / C++ / MFC wpf question

  • Template Question
    M Martin Vladic

    Hm, it seems that discussion boards software stripped some chars from my post. For example, in template specialization definition: template <> class TypeHelper , it stripped "" after class name. Please send me request email, and I will send you correct version of my post. Regards -- Martin

    C / C++ / MFC wpf question

  • Template Question
    M Martin Vladic

    It is invalid C++. Your idea written correctly looks like this: template class TType { public: CString GetAsString() { CString sValue; sValue.Format(GetFormat(), m_tValue); return sValue; } protected: T m_tValue; }; template CString GetFormat(); template <> CString GetFormat() { return "%d"; } template <> CString GetFormat() { return "%.4f"; } Unfortunately, this doesn't work on VC++ 6.0 (GetFormat is called even for float's). Try this: template class TType { public: TType(const T& value) : m_tValue(value) { } CString GetAsString() { CString sValue; sValue.Format(TypeHelper::GetFormat(), m_tValue); return sValue; } protected: T m_tValue; }; template class TypeHelper; template <> class TypeHelper { public: static CString GetFormat() { return "%d"; } }; template <> class TypeHelper { public: static CString GetFormat() { return "%.4f"; } }; -- Martin

    C / C++ / MFC wpf question

  • XML Wrapper classes
    M Martin Vladic

    Commercial: http://www.bristol.com/exactml Free: http://technet.oracle.com/tech/xml/classgen\_cpp/ -- Martin

    The Lounge c++ tools xml question
  • Login

  • Don't have an account? Register

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