[linux-elitists] Nobody's favorite language? C++ and free software

Nick Moffitt nick@zork.net
Wed Mar 26 22:15:07 PST 2003

begin  Greg KH  quotation:
> Except we are using nested structs a bit differently by not placing
> them at the first element, but anywhere else.  Then those nested
> structs are passed around, and subsystems cast backwards to the main
> pointer of their "inherited" object.  Quite fun compiler abuse :)

	So why "anywhere else"?  I meant that the first element of
struct foo is an instance of struct foo_parent, so that you can
reasonably treat any struct foo as a foo OR a foo_parent (or
foo_grandparent, if foo_parent followed the convention) and so forth. 

	The bonus is that this mechanism really *is* just plain C, and
it's readily self-apparent to anyone who's used C for anything beyond
a CS110 course.

	You don't get multiple inheritance, operator overloading, or
type templating.  What you get is an elegant implementation of
polymorphism, and that's the first thing people generally want from an
OO system.



More information about the linux-elitists mailing list