gpt4 book ai didi

c++ - 以下 if 语句中的条件是做什么的?

转载 作者:行者123 更新时间:2023-11-28 02:38:14 28 4
gpt4 key购买 nike

if (read(read(cin, data1), data2))

问题是C++ Primer 5th Edition 的练习。 read 函数定义如下:

std::istream &read(std::istream &is, Sales_data &item)
{
double price = 0;
is >> item.bookNo >> item.units_sold >> price;
item.revenue = price * item.units_sold;
return is;
}

if 语句中的条件是做什么的?我无法理解这一点。

最佳答案

What does the condition in the if statement do? I can't understand this point.

你不应该要求练习的答案;这降低了学习效果。再次浏览章节和函数,看看您是否能找到重点。

如果你把它写得有点不同,也许它会有所帮助:

   std::istream& a = read(cin, data1);
std::istream& b = read(a , data2);
if (b)
// ...

关于c++ - 以下 if 语句中的条件是做什么的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26818628/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com