add cpp code of buildOutputLayer.m, but the code without test