A
A
Anther2020-10-22 22:05:24
C++ / C#
Anther, 2020-10-22 22:05:24

Are classes possible in C?

Is it physically possible to implement OOP with encapsulation, inheritance and polymorphism in C based on structures?

Answer the question

In order to leave comments, you need to log in

7 answer(s)
D
Developer, 2020-10-22
@samodum

Of course available. C++ is written in C

S
Sergey Gornostaev, 2020-10-23
@sergey-gornostaev

Is it possible in procedural programming to mimic OOP?

V
Vladimir Korotenko, 2020-10-22
@firedragon

The question is why?
The answer is not complete.
For example, windows is written in C, but many features are implemented precisely through the transfer of pointers to a pre-prepared structure, but does it make sense now?

P
planc, 2020-10-23
@planc

https://habr.com/en/post/348204/

C
CityCat4, 2020-10-23
@CityCat4

How to make a trolleybus from a loaf of bread
But why?

A
Alan Gibizov, 2020-10-23
@phaggi

Object oriented C

V
Vasily Bannikov, 2020-10-23
@vabka

Yes, you just need to add a field to the beginning of each structure, in which pointers to functions will be stored in some uniform form.
More specific examples have already been thrown out here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question