Re: Adding the ability to add functions into structures?
- From: "Malcolm" <regniztar@xxxxxxxxxxxxxx>
- Date: Sat, 31 Dec 2005 12:23:31 +0000 (UTC)
"Jack Klein" <jackklein@xxxxxxxxxxx> wrote
> 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.
>
Inheritance is crucial.
An object is any set of data items that are "part of the same thing". C
structures are therefore objects. (The C standard further specifies that an
object must be stored contigously in memory. This is a language issue and a
fairly obvious thing to do, but not strictly necessary).
A program becomes "object-oriented" not when it uses objects, but when the
objects enter into relationships with each other. In C++ like most lanauges
that support obect-orientation, this is achieved via inheirtance. However
there are other ways, for example Microsoft Windows objects all respond to
the same message system, Java interfaces specify common methods, text
adventure objects have verb handlers.
.
- Follow-Ups:
- Re: Adding the ability to add functions into structures?
- From: Jack Klein
- Re: Adding the ability to add functions into structures?
- References:
- Adding the ability to add functions into structures?
- From: Albert
- Re: Adding the ability to add functions into structures?
- From: Jack Klein
- Adding the ability to add functions into structures?
- Prev by Date: Re: String reversing problem
- Next by Date: Re: Printf question.
- 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
|