No member named ” in ”. Why did it happen and how do I fix it?

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.

Leave a Comment