I'm trying to downcast from a GameEvent* to a Shot*
I'm getting a segfault because when I call getShooter() there's no information to get. I was wondering what I'm doing wrong.Code:void Game::addEvent(GameEvent* event) { boardTime=&(Time)(event->getTime()); int timePeriod=event->getTime().getPeriod(); if (timePeriod==2 && halfTimeouts==0) { halfTimeouts=1; homeTimeouts=3; awayTimeouts=3; } if (event->getType().compare("shot")==0) { Shot* shot=dynamic_cast<Shot*>(event); if (shot != 0) { cout << shot->getShooter()->getName()<<endl; } else { cout << "This object is not of type Shot"<<endl; } if (shot->getSuccessful()==1) { if (shot->getShooter()->getTeam()==homeTeam) { homeScore+=shot->getType(); } else { awayScore+=shot->getType(); } } events.push_back(event); } }