class type casting

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stmfc
    New Member
    • May 2007
    • 65

    class type casting

    in java, class types do not allow casting.
    to convert one to other, there must be special methods (except inheritance)
    does c++ allow class type casting? (except inheritance)
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    Originally posted by stmfc
    in java, class types do not allow casting.
    to convert one to other, there must be special methods (except inheritance)
    does c++ allow class type casting? (except inheritance)
    Yes C++ does.
    You have to use operator oveloading.

    kind regards,
    Dmjpro.

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Originally posted by stmfc
      does c++ allow class type casting? (except inheritance)
      It does. But only to support calling relic C functions and perhaps file I/O. If you have to do this for other reasons your C++ design is probably screwed up.

      Remember, after any cast the type safety of your program has been compromised.

      Comment

      Working...