Re: Object-oriented programming in standard ANSI C



On Fri, 17 Nov 2006 10:53:58 -0800, "E. Robert Tisdale" wrote:
Thierry Chappuis wrote:
I'm interested in techniques used to program in an object-oriented way
using the C ANSI language. of such techniques?

Please find attached a C implementation
of Bjarne Stroustrup's famous Shape class.

Your approach is similar to the results of my experiments with OO in
C. You can increase encapsulation when you only forward declare your
structs (e.g. struct Shape) in the header files. Also some functions
(e.g. actualShape_draw) can be removed form the header and made
'private', i.e. static, in the respecive *.c file.

Best regards,
Roland Pibinger
.