こんにちは私は2つのクラスを持っています。1つはInstructionと呼ばれ、もう1つは命令クラスから継承するLDIと呼ばれます。
class Instruction{
protected:
string name;
int value;
public:
Instruction(string _name, int _value){ //constructor
name = _name;
value = _value;
}
~Instruction(){}
Instruction (const Instruction &rhs){
name = rhs.name;
value = rhs.value;
}
void setName(string _name){
name = _name;
}
void setValue(int _value){
value = _value;
}
string getName(){
return name;
}
int getValue(){
return value;
}
virtual void execute(){}
virtual Instruction* Clone() {
return new Instruction(*this);
}
};
/////////////end of instruction super class //////////////////////////
class LDI : public Instruction{
void execute(){
//not implemented yet
}
virtual Instruction* Clone(){
return new LDI(*this);
}
};
次に、Instruction型のポインターを作成し、LDI型の新しいインスタンスを指すようにします。
Instruction* ptr;
ptr = new LDI("test", 22);
次のコンパイラエラーが発生します。私が間違っていることについて何か考えはありますか?
functions.h:71: error: no matching function for call to ‘LDI::LDI(std::string&, int&)’
classes.h:54: note: candidates are: LDI::LDI()
classes.h:54: note: LDI::LDI(const LDI&)