It would be good to give a default value to the number of classes here to avoid potential errors due to uninitialised memory.