Тэги:
#implement_OOP #C_programming #oop_in_C_programmingКомментарии:
If you still have to pass the structure pointer inside the parenthesis then there's NO point to this. Might as well go the normal route and just call the function without doing struct.get
ОтветитьThank you so much
Ответитьforget const and static in files, for encapsulation
ОтветитьOoooooh that actually is amazing, but I think that you can actually create constructors (and subsequently, destructors), by include all of the function bindings in the init() function. The destructor can be simple, by calling the free() function.
ОтветитьI know that a C++ precompiler does this, kinda the same behind the scene. And I wanted to say that what happens to inheritance? How can I make the same?
ОтветитьYou can also do
struct Person p1 = {&setAge, &getAge};
THANK YOU VERY MUCH
ОтветитьI haven't checked the latest C or C++ standards but about 15 years ago the only formal difference between a struct and a class is that by default everything within a struct is public while everything within a class is private.
Ответить