Hand-written translation of C++ object-model features into C.
Based on a PublicTransport class hierarchy: constructors / destructors,
copy/assignment, inheritance-by-embedding, vtables, virtual dispatch,
polymorphic containers, and template-as-macro (MAX_FUNC).
cpp2c/
├── src/cpp2c.c
├── Makefile
└── README.md
make
make run| C++ | C in this demo |
|---|---|
| class / private data | struct + nested private struct |
| constructor / destructor | XxxCtor / XxxDtor |
| virtual function | function pointer in vtable |
| inheritance | embedded base struct |
new / delete |
malloc + ctor / dtor + free |
| template | preprocessor macro (MAX_FUNC) |