c++ classes crashing on copying