私は、このプログラムが複数の構造体をファイルに保存して読み込み、編集してからファイルに保存するところに取り組んでいます。私は他人からの助けと数多くのグーグル・アワーの助けはもちろん、コンパイル・エラーに陥っています。どんな助けでも大歓迎です。コンパイラエラー `<<"
コード:
template<typename T>
void writeVector(ofstream &out, const vector<T> &vec);
struct InventoryItem {
string Item;
string Description;
int Quantity;
int wholesaleCost;
int retailCost;
int dateAdded;
} ;
int main(void)
{
vector<InventoryItem> structList;
ofstream out("data.dat");
writeVector(out, structList);
return 0;
}
template<typename T>
void writeVector(ofstream &out, const vector<T> &vec)
{
out << vec.size();
for(vector<T>::const_iterator i = vec.begin(); i != vec.end(); i++)
{
out << *i; // error C2679
}
}
コンパイラエラー:
1>.\Project 5.cpp(128) : error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'const InventoryItem' (or there is no acceptable conversion)
// listed overload variants skipped
1> while trying to match the argument list '(std::ofstream, const InventoryItem)'
1> .\Project 5.cpp(46) : see reference to function template instantiation 'void writeVector<InventoryItem>(std::ofstream &,const std::vector<_Ty> &)' being compiled
1> with
1> [
1> _Ty=InventoryItem
1> ]
短いタイトルを使用し、現在のタイトルを質問の本文に移動することを検討してください。タイトルの書式設定は長続きするものにはあまり適していないため、この質問を読むのは難しいです。 –
ああ申し訳ありません!私は "このコンパイルエラーのヘルプ"があまりにも曖昧だと思った。私は可能な限り具体的にしようとしています! – OneShot
"<< '演算子でコンパイルエラー" – Colin