Re: Object-oriented programming in standard ANSI C



Roland Pibinger wrote:

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.

Unfortunately, your approach precludes automatic function inlining.

Also some functions (e.g. actualShape_draw) can be removed form the header
and made 'private', i.e. static, in the respecive *.c file.

This would preclude any explicit call to function actualShape_draw.
An optimizing C++ compiler will elide the virtual {messenger} function
and call the actual function directly
if it can determine the actual type at compile time.

----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
.



Relevant Pages

  • Name mangling causes link errors ... how disable mangling?
    ... at compile time my compiler is mangling the library function ... header files that say "Treat these as normal C functions without mangling". ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Building a monitoring agent - request for comments.
    ... Not just compile time requirements but run time as well. ... header files. ... the real thing -- looking on MS's FAQ for that, it's missing MFC and ... have those systems installed on the PCs that will run this stuff. ...
    (microsoft.public.win32.programmer.messaging)
  • Re: #include in header file for size_t
    ... Malcolm wrote: ... There's nothing wrong with including header files in header files. ... The waters are muddied further when the compiler supports some form of pre-compiled headers, where a global header that includes all headers can save a significant amount of compile time. ...
    (comp.lang.c)