と一致することができません。関数定義、私は<strong>ボックス</strong>と呼ばれるクラスが<strong>Entitiyエンティティで</strong></p> <p>、私は<code>getWeight()</code>機能を持つ基本クラスから継承したテンプレート
double Entity::getWeight() {
return weight;
}
この関数をBoxクラスでオーバーライドしたいと考えています。私はこれをしました。
template <class T>
double Box<T>::getWeight() {
return weight + inWeight;
}
しかし、それは私にこのエラー
Error C2244 'Entity::getWeight': unable to match function definition to an existing declaration
なぜ私はこのエラーを取得していますを与えますか?
EDIT: Entityクラス
class Entity {
public:
Entity(double weight_in, double length_in, double width_in);
Entity();
double getWidth();
void setWidth(double);
double getLength();
void setLength(double);
double getWeight();
void setWeight(double);
protected:
double weight;
double length;
double width;
};
Boxクラス
#include "entity.h"
template <class T>
class Box : public Entity{
public:
Box(double weight_in, double length_in, double width_in, double maximumAllowedWeight_in);
Box();
Box(Box<T>&);
};
「エンティティ」はどのように宣言していますか?関連コードを表示してください。 – songyuanyao