Getting close to working C++ code.