How to implement a wrapper around C 'objects' using smart pointers?
问题 I am using a C library which uses raw pointers from C++. Therefore, I'm looking into wrapping all the pointers to C objects in C++ classes and turning them into smart pointers. I've built a working example: #include <iostream> using namespace std; // the C library is oop: using structs and naming conventions. Like this: // C library declarations struct Animal_s { int age; }; typedef struct Animal_s Animal; Animal* make_animal(int age); void free_animal(Animal* animal); Animal* do_something