I see in C++ there are multiple ways to allocate and free data and I understand that when you call malloc you should call free and when you use the
malloc
free
In the following scenario, we can't use new since it calls constructor.
class B { private: B *ptr; int x; public: B(int n) { cout<<"B: ctr"<x = n + 10; } ~B() { //delete ptr; free(ptr); cout<<"B: dtr"<