c++ virtual function not being overridden