istream对象的使用问题
#include <iostream>using namespace std;
void f(istream i);//声明为函数的形参就不会报错
int main()
{
//istream s;//说basic_istream类中的char_traits是保护类型的
return 0;
}
2019-01-02 22:17
2019-01-03 08:45
2019-01-03 10:06


2019-01-03 10:35
2019-01-03 10:38
2019-01-03 11:01
2019-01-03 12:10
程序代码:#include <iostream>
using namespace std;
void f( std::ostream& os )
{
os << "123";
}
int main( void )
{
f( cout );
}
2019-01-03 12:18
2019-01-03 19:44
程序代码:#include <iostream>
using namespace std;
class Foo {
private:
ostream &os;
public:
Foo(ostream &os) : os {os} {}
template <size_t N>
void func(int (&arr)[N]) {
for(auto c : arr) {
this->os << c;
}
}
};
int main(int argc, char *argv[]) {
Foo f(cout);
int arr[] {1, 2, 3, 4, 5};
f.func(arr);
}
2019-01-03 22:44