C++ is a statically-typed language. You use pat
using a pointer to animal
. So the compiler checks if animal
has the member function PrintSound()
. It does not have it, so there is a compilation error raised. You need to add the declaration of PrintSound
to animal
(probably a pure virtual function) to fix this.