adding class scaffolding for better C++ design
replaced malloc calls with new/delete