答案 0 :(得分:5)
您需要一个virtual function来覆盖每个特定类中的行为。例如:
class Person
{
public:
//pure virtual function, i.e a function that doesn't have an implementation
virtual int registrationFee() = 0;
};
class Student : public Person
{
public:
int registrationFee() override
{
//whatever logic implements this function
}
};