我知道一个函数不能在没有括号的情况下被调用,但是,假设我有这样一段源代码:
#include<iostream>
using namespace std;
ostream& test(ostream& os){
os.setf(ios_base::floatfield);
return os;
}
int main(){
cout<<endl<<scientific<<111.123456789;
cout<<endl<<test<<111.123456789;
}
/// Output:
/// 1.11235e+002
/// 111.123
左移运算符没有重载,但是当我在main
函数中的cout
里调用test(ostream& os)
函数时,它不需要任何圆括号。我的问题是为什么?
.hpp
是用于C++的。 - RamblingMadint
等相同的值语义符号处理不同类型的效用(和美学)?……这非常优雅和强大。 - Tony Delroy