Possible Duplicate:
Can you write object oriented code in C?
Does C support simple class without polymorphism, inheritance etc.?
I need only definition of class and methods.
Possible Duplicate:
Can you write object oriented code in C?
Does C support simple class without polymorphism, inheritance etc.?
I need only definition of class and methods.
C has no class concept on its own.
It is possible, however, to implement something like that:
struct stuff {
void (*do_it)(void);
void (*close)(void);
};
struct stuff new(void) {
struct stuff ret;
ret.do_it = ...;
ret.close = ...;
return ret;
}
int main() {
struct stuff s = new();
s.do_it();
s.close();
}
You can use a struct and store function-pointers in it.