Substitute for Assignment 3 implementation in C++