pass by reference in cpp files for subclasses