On 30 Dec 2005 17:12:33 -0800, "Albert"
<> wrote in comp.lang.c:
> So structures are useful to group variables, so you can to refer to a
> collection as a single entity. Wouldn't it be useful to also have the
> ability to collect variable and functions?
>
> Ask K&R say, C programs consist of variables to store the input and
> functions to manipulate them.
>
> This would make C object-oriented - how cool would that be?
>
> Are there any problems with adding the ability to have functions
> encapsulated in structures?
It's already been done. They discuss it in comp.lang.c++, down the
hall. And in comp.lang.java, and I'm sure also in whatever group it
is on Microsoft's server that is devoted to C#.
I know I'll get flamed for this, but with the exception of inheritance
this is really nothing but syntactical sugar. You can write object
oriented programs in C right now.
A perfect example is the FILE data type, declared an <stdio.h>. It
has a creator, fopen(), a destructor, fclose(), and all sorts of
methods you can invoke on it via its pointer, such as fprintf(),
fscanf(), fread(), fwrite(), between its successful creation and its
destruction.
--
Jack Klein
Home:
http://JK-Technology.Com
FAQs for
comp.lang.c
http://c-faq.com/
comp.lang.c++
http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html