C ++ Primer ex 8.3 [英] C++ Primer ex 8.3

查看:87
本文介绍了C ++ Primer ex 8.3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到错误,找不到问题:


/ * C ++ Primer - 4 / e

*

*第8章,练习8.3

*语句

*写一个函数,它接收并返回一个istream& ;.函数

应该读取流,直到它击中EOF并且应该打印它读取到标准输出的
。重置流以使其有效并且

返回流。

*

* /


#include< iostream>

#include< istream>


istream& stream_game(std :: istream& i_strm)/ *这是第14行* /

{

而(std :: istream> i_strm)

{

std :: cout<< i_strm;

}


std :: istream.clear();


返回i_strm;

}

int main()

{

std :: istream& i_strm;

stream_game(i_strm);


返回0;


}

/ * OUTPUT

~ / programming / cpp $ g ++ -ansi -pedantic -Wall -Wextra ex_08.03.cpp

ex_08。 03.cpp:14:错误:预期的构造函数,析构函数或类型
$'$ b'转换''&''令牌〜/ programming / cpp $


* /

-
http://arnuld.blogspot。 com

解决方案

g ++ -ansi -pedantic -Wall -Wextra ex_08.03.cpp


ex_08.03.cpp:14:错误:预期构造函数,析构函数或类型
$'$'b'转换''&''令牌〜/ programming / cpp





* /

-
http://arnuld.blogspot.com


arnuld写道:
< blockquo te class =post_quotes>
我收到错误,找不到问题所在:


/ * C ++ Primer - 4 / e

*

*第8章,练习8.3

*语句

*写一个函数,它接收并返回一个istream& ;.函数

应该读取流,直到它击中EOF并且应该打印它读取到标准输出的
。重置流以使其有效并且

返回流。

*

* /


#include< iostream>

#include< istream>


istream& stream_game(std :: istream& i_strm)/ *这是第14行* /



也许这应该是行开头的std :: istream。 br />


{

while(std :: istream> i_strm)

{

std :: cout<< i_strm;

}


std :: istream.clear();


返回i_strm;

}


int main()

{

std :: istream& i_strm;

stream_game(i_strm);


返回0;


}

/ * OUTPUT

~ / programming / cpp


I get an error, can''t find what is the problem:

/* C++ Primer - 4/e
*
* Chapter 8, exercise 8.3
* STATEMENT
* write a function that takes and returns an istream&. the function
should read the stream untill it hits the EOF and should print what it
read to the standard output. reset the stream so that it is valid and
return the stream.
*
*/

#include <iostream>
#include <istream>

istream& stream_game( std::istream& i_strm) /* this is line #14 */
{
while( std::istream >i_strm )
{
std::cout << i_strm;
}

std::istream.clear();

return i_strm;
}
int main()
{
std::istream& i_strm;
stream_game( i_strm );

return 0;

}

/* OUTPUT
~/programming/cpp $ g++ -ansi -pedantic -Wall -Wextra ex_08.03.cpp

ex_08.03.cpp:14: error: expected constructor, destructor, or type
conversion before ''&'' token ~/programming/cpp $

*/
--
http://arnuld.blogspot.com

解决方案

g++ -ansi -pedantic -Wall -Wextra ex_08.03.cpp

ex_08.03.cpp:14: error: expected constructor, destructor, or type
conversion before ''&'' token ~/programming/cpp




*/
--
http://arnuld.blogspot.com


arnuld wrote:

I get an error, can''t find what is the problem:

/* C++ Primer - 4/e
*
* Chapter 8, exercise 8.3
* STATEMENT
* write a function that takes and returns an istream&. the function
should read the stream untill it hits the EOF and should print what it
read to the standard output. reset the stream so that it is valid and
return the stream.
*
*/

#include <iostream>
#include <istream>

istream& stream_game( std::istream& i_strm) /* this is line #14 */

maybe that should be std::istream at the beginning of the line.

{
while( std::istream >i_strm )
{
std::cout << i_strm;
}

std::istream.clear();

return i_strm;
}
int main()
{
std::istream& i_strm;
stream_game( i_strm );

return 0;

}

/* OUTPUT
~/programming/cpp


这篇关于C ++ Primer ex 8.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆