Tuesday, May 5, 2009

Inheritance

Inheritance isn't really anything new to me. It is one of those things that is drilled into our heads during our first few CS courses (or that's the goal anyway).

But most of that involved inheritance with Java. Simple inheritance, more or less. The type where a class can only inherit from one other class (i.e., only one parent).

But with C++ (and probably other languages), it is evident that inheritance can be much more complicated. Multiple inheritance, protected/private inheritance, double inheritance, virtual inheritance, etc. Some of these really involve drawing a picture of the whole hierarchy to understand what is going on. Granted, some things seem to be affected by odd design choices (e.g., using the same name for instance variables in each class), but it is helpful to know exactly how to work with the classes in these situations. Well...hopefully it is helpful outside of just taking tests about inheritance anyway. :)

No comments:

Post a Comment