Is there a way(function) to distingusih between different data types?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • WuJianWei
    New Member
    • Mar 2007
    • 10

    Is there a way(function) to distingusih between different data types?

    Is there a way(function) to distingusih between different data types?

    if u can, provide me with the code...

    thank u...
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Have a look at the typeid() operator (include <typeinfo>) or else simply use
    dynamic_cast<.. .>(...)

    kind regards,

    Jos

    Comment

    • WuJianWei
      New Member
      • Mar 2007
      • 10

      #3
      Thank u so much about it !!

      Comment

      • AdrianH
        Recognized Expert Top Contributor
        • Feb 2007
        • 1251

        #4
        F.Y.I.

        When using dynamic type casting or using typeid you must ensure that the compiler has that feature enabled. Some disable it by default which will result in undefined behavior.


        Adrian

        Comment

        • weaknessforcats
          Recognized Expert Expert
          • Mar 2007
          • 9214

          #5
          dynamic_cast requires run-time type identification and that requires a database for every object with virtual functions. That will slow your program.

          Also, typeid and dynamic_cast don't work for objects that have no virtual functions.

          What are you trying top do exactly??

          Comment

          Working...