我想確定如何在派生類中命名我的虛函數。派生類中的虛函數命名
Base.h
class Base
{
public:
virtual void Virtual() = 0;
};
Derived.h
class Derived : public Base {
public:
void Virtual();
};
Derived.cpp
Derived::Virtual() // or Base::Virtual
{
cout << "Derived Virtual.\n";
}
我是否在實現文件中使用Derived :: Virtual或Base :: Virtual,以及哪種方法會遇到問題?
爲什麼你想爲'Derived'定義函數時需要'Base ::'? – NathanOliver