Improves encapsulation of Problem 12 C++ solution