-3
int main( )
{
    Base *ptrBase = new Derived( 50, 60, 70 ); 
    Derived *ptrDerived = ( Derived*)ptrBase;
    ptrDerived->printRecord( );
    delete ptrBase;

    return 0;
}
John Kugelman
  • 349,597
  • 67
  • 533
  • 578
  • 1
    To plant the picture in your head: Class inheritance hierarchies are usually drawn vertically from the root at top and the inheritance tree's leafs at bottom. So the directions placed before the verb _casting_ refer to this visualization. – πάντα ῥεῖ Jan 17 '21 at 12:52
  • 1
    you cast Derived to Base at first line, then cast from Base to Derive at second line. which you ask? – apple apple Jan 17 '21 at 13:28
  • since I think it's not unnatured to call derived is build on top of base, I would prevent use `up` and `down` myself. Simply call it *cast to base* or *case to xxx* is better imho. – apple apple Jan 17 '21 at 13:30

1 Answers1

2

Upcast is from derived to base, downcast from base to derived. So in your case it is a downcast.

Werner Henze
  • 16,404
  • 12
  • 44
  • 69