much simplified c++ file, j not outputting whole array