Adding Object-Oriented Functionality to a POD Type

Sometimes, legacy code that contains Plain Old Data (POD) types (i.e., dumb structs that don’t have any member functions) can use an object-oriented “face lift”, e.g., adding a constructor or member functions. Instead of adding the new functionality directly into the POD struct, it’s better to derive a new class from it and add the new object-oriented functionality&#151member functions, constructor and destructor?to the newly-derived class. Leaving the struct intact will ensure binary compatibility with other code components that still use the original struct.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: