Is it possible to implement dot notation in C (OOP) a la Python?
Something like:
struct myClass {
...
...
}
And then have a method on that struct like:
myClass.someMethod();
Is it possible to implement dot notation in C (OOP) a la Python?
Something like:
struct myClass {
...
...
}
And then have a method on that struct like:
myClass.someMethod();
Yes, someMethod()
will be a function pointer:
#include <stdio.h>
typedef struct
{
void (*someMethod) (void);
}Test;
void asd (void)
{
printf("works");
}
int main(void)
{
Test test;
test.someMethod = asd;
test.someMethod(); // will print works
}