Thread: casting

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    11

    casting

    Hello,

    I have a type Base and two identical types DerivedOne and DerivedTwo that are derived from Base.

    I receive a Base * I know is a DerivedOne*.
    Could I cast from DerivedOne* to DerivedTwo?
    If yes how?

    BR,
    Cristian

    PS
    processMessage(Base * msg)
    {
    DerivedOne* pDerivedOne = dynamic_cast<DerivedOne *> msg;
    HOW TO DO
    DerivedTwo * pDeriveTwo = CAST<> pDerivedOne? Is it possible?
    }

  2. #2
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    i don't think it's possible. while Base and Derived1 have all similar members, Derived1 and Derived2 can be very different.

  3. #3
    Registered User
    Join Date
    Aug 2002
    Posts
    11

    casting

    Sorry for not being clear,

    Derived1 and Derived2 are identical, I receive a message Base* I know is Derived1*.
    Could I cast the message to Derived2?

    Cristian

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Casting
    By morvick in forum C++ Programming
    Replies: 2
    Last Post: 06-17-2007, 11:06 PM
  2. Casting Question (I think)
    By fayte in forum C Programming
    Replies: 6
    Last Post: 03-08-2006, 05:31 PM
  3. casting the system exstracted date into seperate ints
    By bazzano in forum C Programming
    Replies: 1
    Last Post: 08-30-2005, 12:17 AM
  4. Type casting
    By Lionmane in forum C Programming
    Replies: 28
    Last Post: 08-20-2005, 02:16 PM
  5. question about casting pointers/other types also??
    By newbie02 in forum C++ Programming
    Replies: 3
    Last Post: 08-07-2003, 05:01 AM