Re: Adding the ability to add functions into structures?




"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.


.



Relevant Pages

  • Re: Object recreating itself as a different class type ?
    ... In version 0.02 I will find out if inheritance can help solve the problem. ... destructor is called. ... destructor Destroy; override; ...
    (alt.comp.lang.borland-delphi)
  • Re: Object recreating itself as a different class type ?
    ... As promised I tried again by this time using inheritance and surprisingly ... However Delphi's hint system is giving a unnecessary and weird hint: ... destructor is called. ... destructor Destroy; override; ...
    (alt.comp.lang.borland-delphi)
  • Re: CArray
    ... When you delete the bass class pointer, the virtual destructor of B is needed to ensure proper destruction of the derived class D. ... [I do use multiple inheritance quite a lot, though less than I used to, and I avoid doing it on MFC classes these days.] ... But the general wisdom is that you *can* export these from DLLs. ...
    (microsoft.public.vc.mfc)