1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Casting Base Class to Derived

Discussion in 'C++' started by santhoshks, Jun 13, 2012.

  1. santhoshks

    santhoshks New Member

    Joined:
    Jun 2, 2012
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Software Engineer
    Hi everyone. Why it is not possible to cast/convert Base Class Object to Derived Class. Can anyone please explain this. For Example

    Base_Class * ptr_b = new Base_Class;
    Derived_Class * ptr_c;
    ptr_c = dynamic_cast< Derived_Class *>(ptr_b);// FAILS:depressed:
     

Share This Page