As far as I know, the terminology comes from how the inheritance hierarchy is traditionally displayed, with the extending types at the bottom, and the parent types at the top.

This is a bit pointless, unless you feel like calling the following leftcasting and rightcasting.

horizontal inheritance hierarchy

I am not looking for opinions why the terminology is as is, but they are more than welcome as comments. I am looking for references on who first introduced up and downcasting, and why they decided on that name.

  • 1
    Although they're somewhat self-explanatory, I haven't heard anyone actually use these terms. Have ye a reference? IOW: "You upcast to an object which can do less, and you downcast to an object which can do more." [citation needed]
    – Task
    Dec 22, 2011 at 14:41
  • 1
    I consider upcasting safer (you go towards a type that's guaranteed to have at least a subset of the members of the starting type), whereas when downcasting you can't be really sure of what you'll find. Safer -> better, so the typical reasoning you use, works. [/opinion]
    – yannis
    Dec 22, 2011 at 14:43
  • 2
    And quite more importantly. Did you read the article from where you got the dog / cat image? If not, it supports my previous comment: upcasting is safer, as it can never fail, downcasting on the other hand can. Also I'd add that upcasting gets us at a higher abstraction level (if that makes it easier for you to remember).
    – yannis
    Dec 22, 2011 at 15:24
  • 1
    It's not so easy to search for their origins because upcasting and downcasting have older meanings. But perhaps those meanings influenced the OOP words. But the Ngram shows big increases around 1980 and 1995. The earliest certain references to downcast[ing] I found are from 1992 in C++ literature...
    – Hugo
    Dec 23, 2011 at 11:32
  • 1

2 Answers 2


Basically the down- and up-cast is the logical continuation of the subtype (subclass in OOP) and supertype (superclass respectively), e.g. the classical representation of the derived type to be located below the original type -- subtype.

If we search for the term subtyping we find the following (Wikipedia):

The notion of subtyping in programming languages dates back to the 1960s; it was introduced in Simula derivatives. The first formal treatments of subtyping were given by John C. Reynolds in 1980 who used category theory to formalize implicit conversions, and Luca Cardelli (1985).

So, as many other things, it originated in something vaguely called here as "Simula derivatives" (probably early OOP languages). Simula, however, already has the notion of subclass, but does not feature all the properties of OOP.

  • As stated in my question: "the terminology comes from how the inheritance hierarchy is traditionally displayed". This doesn't explain the reason why "sub" and "super" should be displayed as "up" and "down". I already added SIMULA as a comment. Dec 22, 2011 at 15:42
  • 1
    Hmm... So, you don't see connection between "sub" and "down"? What about subtitles, Subzero, subliminal and other common English words? Dec 22, 2011 at 15:50
  • 1
    P.s.: In SIMULA the concept of inheritance was originally called, "concatenation", and later "prefixing". I don't recall reading about subtyping or supertyping when reading the SIMULA documentation. I believe this is a term which only emerged later. Dec 22, 2011 at 15:51
  • Just did some rereading of the SIMULA documentation. Subclass is indeed used, but not subtype. By rereading your answer I now know what you meant. :) Would still prefer an actual reference, but I see how you go from "sub" to lower. Dec 23, 2011 at 11:51
  • 3
    @StevenJeuris: it's actually not that clear cut; a subclass typically have more features than the parent class; in an alternate world, we may be using the term "promote" or "demote" for "downcasting" and "upcasting" respectively, if we think that a supertype is a subordinate of the subclass because a subclass is more powerful/has more features than the superclass. IMO the real reason why these terms are used are mostly historical accidents.
    – Lie Ryan
    Jan 17, 2012 at 5:20

The oldest reference I've found yet is from Sep 1990, in a Usenet post.

The library referenced there is the NIHCL (available from the Software Preservation Group), which contains this code (MI is "multiple inheritance"):

#ifdef MI

#define DECLARE_CASTDOWN(classname) \
    static classname& castdown(Object& p) \
        { return *(classname*)(&p ? p._safe_castdown(*desc()) : 0); } \
    static const classname& castdown(const Object& p) \
        { return *(const classname*)(&p ? p._safe_castdown(*desc()) : 0); } \
    static classname* castdown(Object* p) \
        { return (classname*)(p ? p->_safe_castdown(*desc()) : 0); } \
    static const classname* castdown(const Object* p) \
        { return (const classname*)(p ? p->_safe_castdown(*desc()) : 0); } \


#define DECLARE_CASTDOWN(classname) \
    static classname& castdown(Object& p)           { return (classname&)p; } \
    static const classname& castdown(const Object& p)   { return (const classname&)p; } \
    static classname* castdown(Object* p)           { return (classname*)p; } \
    static const classname* castdown(const Object* p)   { return (const classname*)p; } \


The book that this code was included with (Data Abstraction and Object-Oriented Programming in C++) also uses the term "castdown".

The term "castdown" also seems to predate "downcast", at least on Usenet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.