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

Greg KH greg@kroah.com
Wed Mar 26 17:09:33 PST 2003


On Wed, Mar 26, 2003 at 03:13:26PM -0800, Nick Moffitt wrote:
> 
> 	I always did it with nested structs.  The first element of a
> struct is an instance of the parent struct, so you can always cast the
> thing and treat it like the parent.  You need to be careful with
> memory management, but throwing big structs around on the stack is bad
> news most of the time anyway.
> 
> 	Add in function pointers and use self parameters and you've
> got most of the functionality that basic OOP provides.

Sounds like large chunks of the Linux kernel these days.

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 :)

greg k-h



More information about the linux-elitists mailing list