Re: Object orientation.....
- From: "Malcolm" <regniztar@xxxxxxxxxxxxxx>
- Date: Sat, 3 Sep 2005 04:56:25 +0000 (UTC)
"Vishal Naidu" <naiduvishal@xxxxxxxxx> wrote
> is it really possible to write object oriented code in C ?
> and if yes how do we achieve abstration, polymorhism , hierarchy etc.
> in C
>
The advantage of using C rather than an object-oriented language is that you
get to decide the protocol.
For instnace you could define a struct OBJECT
typedef struct
{
void **interfaces;
char **interfacenames;
in Ninterfaces;
} OBJECT;
Then you can have a function void *get_interface(OBJECT *obj, char *name)
This queries the object for an interface, and returns it.
eg
typedef struct
{
void *draw(unsigned char *rgb, int width, int height, int x, int y);
} DRAWABLE;
Thus you build your object from interfaces.
.
- References:
- Object orientation.....
- From: Vishal Naidu
- Object orientation.....
- Prev by Date: Re: C parser document
- Next by Date: Re: Always true
- Previous by thread: Re: Object orientation.....
- Next by thread: Re: Object orientation.....
- Index(es):
Relevant Pages
|