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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Check Variable is CString or Integer (RTTI in MFC/ATL)

Check Variable is CString or Integer (RTTI in MFC/ATL)

Scheduled Pinned Locked Moved C / C++ / MFC
c++data-structuresquestion
4 Posts 4 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.
  • Q Offline
    Q Offline
    QuickDeveloper
    wrote on last edited by
    #1

    hi i want to check whether variable in given generic array(like CArray) is CString or integer etc.I tried using IsKindOf but it doesn't work for CString.so is there any method for Runtime type Identification??

    "Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"

    C J N 3 Replies Last reply
    0
    • Q QuickDeveloper

      hi i want to check whether variable in given generic array(like CArray) is CString or integer etc.I tried using IsKindOf but it doesn't work for CString.so is there any method for Runtime type Identification??

      "Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"

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

      :confused: Correct me if I'm wrong but your array is a template array. So you have to declare something like this: CArray<CString> myArray; So, you know exactly what you declared, isn't it ?

      Cédric Moonen Software developer
      Charting control [v1.2]

      1 Reply Last reply
      0
      • Q QuickDeveloper

        hi i want to check whether variable in given generic array(like CArray) is CString or integer etc.I tried using IsKindOf but it doesn't work for CString.so is there any method for Runtime type Identification??

        "Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"

        J Offline
        J Offline
        jhwurmbach
        wrote on last edited by
        #3

        QuickDeveloper wrote:

        I tried using IsKindOf but it doesn't work for CString

        Use the (standardized) RTTI-feature of C++! The only reason that IsKindOf exists is that MFC predates the C++-Standard. Something like CString* pCStr = dynamic_cast(vec[i]); if( !pCStr) { ...must be something different... }

        Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all.
        Douglas Adams, "Dirk Gently's Holistic Detective Agency"

        1 Reply Last reply
        0
        • Q QuickDeveloper

          hi i want to check whether variable in given generic array(like CArray) is CString or integer etc.I tried using IsKindOf but it doesn't work for CString.so is there any method for Runtime type Identification??

          "Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"

          N Offline
          N Offline
          Naveen
          wrote on last edited by
          #4

          QuickDeveloper wrote:

          so is there any method for Runtime type Identification??

          typeid()

          nave [OpenedFileFinder]

          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