Thursday, August 26, 2010

C orientado a objetos

#include

typedef struct {
   void (*function)();
   int i;
} class;

void function( class *this )
{
   this->i++;
   printf( "Function called %d time(s).\n", this->i );
}

class Class()
{
   class a;

   a.i = 0;
   a.function = &function;
   printf( "Constructor called\n" );
   return a;
}

int main( int argc, char* argv[] )
{
   int count;

   class test = Class();

   for( count = 0; count <>
   test.function( &test );

return 0;
}

No comments:

Blog Archive