函数中的默认ofstream类参数 [英] Default ofstream class argument in function
本文介绍了函数中的默认ofstream类参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有功能.如果用户未在此函数中提供 ofstream
元素:
I've got function. If user didn't provide ofstream
element into this function:
bool isPolpierwsza(int, bool = false, ofstream = NULL);
比我要指定标高"
bool isPolpierwsza(int liczba, bool wypisz, ofstream plik)
转换为 NULL
值.
我的编译器放置错误:
2.9.cpp:5:48:错误:没有从'long'到'ofstream'(又名'basic_ofstream')的可行转换
bool isPolpierwsza(int,bool = false,ofstream = NULL);
如何设置ofstream的默认值,使其像 NULL
或"false"一样对待?
How to setup default value to ofstream to be treated like NULL
or "false"?
推荐答案
您可以使用两个重载,其中之一不采用 std :: ofstream
参数:
You can use two overloads, one of which doesn't take the std::ofstream
argument:
bool isPolpierwsza(int liczba, bool wypisz)
{
return isPolpierwsza(liczba, wypisz, /* your own argument */);
}
这篇关于函数中的默认ofstream类参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文