Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Emulacion de Objetos en C

Esta es una forma de estender el uso de las estructuras para simular el modelo objetual en c

   1  
   2  
   3  struct _Object;
   4  typedef struct _Object Object;
   5  
   6  void Object_init(Object *this);
   7  
   8  struct _Object{
   9         unsigned int id;
  10         void (*init)(Object*);
  11  } obj ={0,&Object_init};
  12  
  13  void Object_init(Object *this){
  14       
  15  }
  16  
  17  int main(int argc, char *argv[])
  18  {
  19      
  20      Object Obj;
  21      Obj.id=1;
  22    return 0;
  23  }
  24  

You need to create an account or log in to post comments to this site.


Click here to browse all 5337 code snippets