Re: Adding the ability to add functions into structures?
- From: Jack Klein <jackklein@xxxxxxxxxxx>
- Date: Fri, 30 Dec 2005 23:07:41 -0600
On 30 Dec 2005 17:12:33 -0800, "Albert"
<albert.xtheunknown0@xxxxxxxxx> 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/~ajo/docs/FAQ-acllc.html
.
- Follow-Ups:
- Re: Adding the ability to add functions into structures?
- From: Malcolm
- Re: Adding the ability to add functions into structures?
- From: Chuck F.
- Re: Adding the ability to add functions into structures?
- From: Richard Heathfield
- Re: Adding the ability to add functions into structures?
- References:
- Adding the ability to add functions into structures?
- From: Albert
- Adding the ability to add functions into structures?
- Prev by Date: Re: Printf question.
- Next by Date: Re: a big problem
- Previous by thread: Re: Adding the ability to add functions into structures?
- Next by thread: Re: Adding the ability to add functions into structures?
- Index(es):
Relevant Pages
|
|