我正在尝试编写一个带ifstream&参数的函数。
void word_transform(ifstream & infile)
{
infile("content.txt");
//etc
}
Run Code Online (Sandbox Code Playgroud)
这给了我一个错误:
类型“ifstream”(又名“basic_ifstream”)不提供调用运算符。
你能帮我看看有什么问题吗?
我在这里有点困惑.我们来看看以下代码:
bool testing(int i) {
if((i%2)==0) {
return true;
} else {
--i;
testing(i);
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
当我这样做时testing(5),我希望函数返回true,因为在某些时候,函数将会5变为4,所以4 % 2 == 0函数将返回,true但事实并非如此.怎么了?