I am exploring some ways of making my code more user friendly.
I find it very intuitive when you have a class in Object Oriented Languages and you can easily get to all the functions that are implemented for it.
I am trying to archieve a similar effect by putting function pointers inside of my struct definitions. The only issue I have with that is having to manually pass the structure pointer every time I use it.
// What I am doing right now.
structure.do_something(&structure);
// What I would like to do.
structure.do_something();
Is there any way of getting a pointer to that struct without passing it to the function explicitly? Also is adding function pointers to your structs a bad practice?
At first, I thought of getting to the structure by using the function pointer and moving an appropriate amount of bytes to the struct definition.
That doesn't work because the function definition is not necessarily defined in the same memory block as the structure. Even if it did work it would be a very tedious approach.