Redian新闻
>
ios 里面的radio怎么消失了?还说打开听歌呢。
avatar
ios 里面的radio怎么消失了?还说打开听歌呢。# Apple - 家有苹果
h*g
1
You have to implement a function that needs to be able to write to both
standard output (typically the console screen) and files. Which one of the
following function declarations satisfies that need?
A.
void print(std::ostream &os);
B.
void print(std::ofstream is);
C.
void print(std::cout);
D.
void print(std::istream is);
E.
void print(std::istream &is);
问下,B 为啥不行呢?A 可以输出到文件吗?网上没找到答案~~~
avatar
t*r
2
ios 里面的radio怎么消失了?还说打开听歌呢。
avatar
s*n
3
cout is an object of class ostream that represents the standard output
stream.
and ostream is the base class of ofstream, which you use to output to a file.
So in A. void print(std::ostream &os);
if you pass a reference to ostream object in the print function, it's OK for
both type.
But in B.void print(std::ofstream is);
Not only you cannot output to the standard output, but also it's passed by
value, that means you make a copy of the ostream object you passed in, and
do output in that copy, which may not work as expected.
Please correct me if I am wrong, thanks.
avatar
f*f
4
哪里有 radio?从来没听过

【在 t**r 的大作中提到】
: ios 里面的radio怎么消失了?还说打开听歌呢。
avatar
h*g
5
thank you so much! I've learned a lot!

file.
for

【在 s*****n 的大作中提到】
: cout is an object of class ostream that represents the standard output
: stream.
: and ostream is the base class of ofstream, which you use to output to a file.
: So in A. void print(std::ostream &os);
: if you pass a reference to ostream object in the print function, it's OK for
: both type.
: But in B.void print(std::ofstream is);
: Not only you cannot output to the standard output, but also it's passed by
: value, that means you make a copy of the ostream object you passed in, and
: do output in that copy, which may not work as expected.

avatar
p*z
6
收费了

【在 t**r 的大作中提到】
: ios 里面的radio怎么消失了?还说打开听歌呢。
avatar
j*n
7
太恶了!

【在 p**z 的大作中提到】
: 收费了
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。