iostreamとfstreamオブジェクトをテンプレート化する方法は?この方法(コードを参照してください)は正しくありません...あなたの助けをありがとう。C++のテンプレート出力:iostreamまたはfstream
template <typename O>
void test(O &o)
{
o << std::showpoint << std::fixed << std::right;
o << "test";
}
int main(int argc, _TCHAR* argv[])
{
std::iostream out1; //Write into console
std::ofstream out2 ("file.txt"); //Write into file
....
test(out1);
test (out2);
return 0;
}
*完全な*最小サンプルプログラム、およびコンパイルまたは実行時に表示される完全なエラーメッセージを提供してください。方法とその理由については、http://sscce.orgを参照してください。 –