Can we emulate OOP in C? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Can we emulate OOP in C?

How many ways are there in this case?

13th Sep 2018, 9:05 PM
Nimrod A. Holguín L.
Nimrod A. Holguín L. - avatar
3 Answers
+ 1
C and C++ are both low level language, so you can do the same things in both. Just repeat manually operations, that c++ compiler does, in c program. It is not a question about the possibility, but question about how much efforts it is required. For example you have to write a virtual table for your classes and call methods through the table. You have to call constructor and destructor each time it is required.
14th Sep 2018, 2:43 AM
Sergey Ushakov
Sergey Ushakov - avatar
+ 2
Yes, you can... I don't know what you mean with ways... See more: https://stackoverflow.com/questions/351733/can-you-write-object-oriented-code-in-c
13th Sep 2018, 9:33 PM
Alexander Santos
Alexander Santos - avatar
+ 2
Thanks for the help of both. They were good answers for me! Thanks for help me!
17th Sep 2018, 5:06 AM
Nimrod A. Holguín L.
Nimrod A. Holguín L. - avatar