C++ writing cubes