:C++(MFC)コードスニペットを簡単に再利用しようとしています。オプションは何ですか?私は繰り返し、次の関数を書いて自分自身を発見した
// This function will try to find the 'item' in 'array'.
// If successful, it will return 'true' and set the 'index' appropriately.
// Otherwise it will return false.
bool CanFindItem(data_type item, const data_type* array, int array_size, int& index) const
{
bool found = false;
index=0;
while(!found && i < array_size)
{
if (array[index] == item)
found = true;
else index++;
}
return found;
}
通常のI /構造体など、クラスごとに同様の機能を記述し、それを必要とします。
私の質問は、このスニペットを書き直すことなく使用する準備ができているかどうかです。私はあなたが現代(すなわちポスト1995)C++を使用することができますし、STLは
@wartim - すみませんでした。しかし、あなたが時間を無駄にする前に、これらの関数を書くことはSTLチュートリアルを見てください。それは最初から複雑ですが、長期的には何年もの無駄な作業を省くことができます –