Jorgen Grahn
4/16/2011 8:23:00 AM
On Wed, 2011-04-13, ramtin wrote:
> hi all,
> i want to implement a class and inheritance in c programing ,
Why not use C++ if you need inheritance?
If you want to use C anyway: stay away from simulating inheritance
unless you desperately need it. I have never seen it done well.
On the other hand, "classes" without inheritance can be a good design
technique for C, and it's easy to do:
constructor: int Foo_create(struct Foo*);
destructor: void Foo_destroy(struct Foo*);
Foo::bar(...): ... Foo_bar(struct Foo*, ...);
Foo::baz(...) const: ... Foo_baz(const struct Foo*, ...);
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .