私は初心者です。私はテンプレートのパラメータとして構造体名を持つクラスの3つの配列をインスタンス化しようとしています。そこから、配列の値を設定するためにミューテータ関数をループして呼び出す必要があります。エラー:(対応できない?)への呼び出しに一致する関数がありません
int main()
{
GenericRecord<Furniture> furnObj[10][3];
GenericRecord<Building> buildObj[10][3];
GenericRecord<Computer> compObj[10][3];
Building b;
Furniture f;
Computer c;
for (int i = 0; i < 3; i++)
{
cout << "Enter the identifier for the furniture: ";
cin >> f.Identifier;
furnObj[i][0].setRecord(f.Identifier);
}
return 0;
}
私は次のようにコンパイラエラーを取得しておいてください。
error: no matching function for call to 'GenericRecord<Furniture>::setRecord(int&)' note: candidate is: note: void GenericRecord<Type>::setRecord(Type) [with Type = Furniture]
私はこの100種類の方法を手直しをしてきた、と私はコンパイルエラーの種類を取得しておきます。私は間違って何をしていますか?ここで
は、テンプレートクラス、メンバー、および構造体である:
struct Furniture
{
int Identifier;
string Description;
float Value;
};
template <class Type>
class GenericRecord
{
private:
Type record;
public:
void setRecord(Type recParam);
};
template<class Type>
void GenericRecord<Type>::setRecord(Type recParam)
{
record = recParam;
}
あなたのケースでは 'Type'は' Furniture'ですが、あなたは 'int'である' f.Identifier'を渡しています。 – DimChtz
'furnObj [i] [0] .setRecord(f.Identifier);'を呼び出すのではなく、 'furnObj [i] [0] .setRecord(f);' – Amadeus
を試してみてください。 'setRecord'という関数があり、' set'を引数として取りますが、あなたはそれをint – pm100