Re: Base class and OOP in C

From: jonathon (j_mckitrick_at_bigfoot.com)
Date: 03/30/05


Date: 30 Mar 2005 11:19:21 -0800


> If you change your declarations slightly, it will work:
>
> typedef struct base {
> whatever;
> } base_t;
>
> typedef struct foo {
> base_t base; /* not a pointer */
> foo_additions;
> } foo_t;

---- <snip> ----

> Now, a pointer to any of these, will be valid as a base_t *.

The only catch is you have to have a definition of base_t for any
derived class. I was hoping to be able to hide the details of this
structure by using a pointer which can be resolved later.



Relevant Pages