virtual functions must: Be overridden in every derived class. Have the same implementation in every derived class. Be declared virtual in the base class. Be declared virtual in every derived class.
Upstudy AI Solution
Answer
Solution

Sign in to Unlock Answers for Free!
A Learning Platform Trusted by Millions of Real Students and Teachers.

Answered by UpStudy AI and reviewed by a Professional Tutor
Extra Insights
Virtual functions are a cornerstone of polymorphism in C++. However, they do *not* need to be overridden in every derived class. A derived class can choose to use the base class's implementation if it fits the needs. The magic happens when you declare a function as virtual in the base class, allowing derived classes to override it if desired, creating a flexible and dynamic behavior. If you forget to declare a function as virtual in the base class, the function will not exhibit polymorphic behavior. That means calling the function on a base class pointer pointing to a derived class object will result in the base class's version being executed, which can lead to confusing results. Just remember: always declare in the base, override in the derived if you want that specific behavior!