4 ms·
C++ was originally a precompiler that generated C code. So it is definitely possible. Generally: - an object is a struct - a method is a function taking a st
by GuB-42 6y ago
C++ was originally a precompiler that generated C code. So it is definitely possible.
Generally:
- an object is a struct
- a method is a function taking a struct (the object) as an argument
- inheritance is done by having a struct that has its parent as the first element
- polymorphism is donc by implementing the vtable manually, these are function pointers
- constructors are functions returning an object (so, a struct)
It is inconvenient but possible. OO is a concept that is not dependent on the language, though some languages make it easier than others.