Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/152.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 我不知道';我不懂ifstream_C++_Iostream_Ifstream - Fatal编程技术网

C++ 我不知道';我不懂ifstream

C++ 我不知道';我不懂ifstream,c++,iostream,ifstream,C++,Iostream,Ifstream,在我的教科书中,它说,ifstream是从文件读取的istream。稍后,在页面下方的示例旁边有一条注释: ifstream ist(name.c_str()); // ist is an input stream for the file named name. 我有点困惑,ifstream和ist()ist之间的区别是您将要使用的ifstream的实例。有一种类型-ifstream,它可以是许多变量的类型 您可以有ist,ist2,ist3,xpto,它们都是ifstream ifstre

在我的教科书中,它说,
ifstream
是从文件读取的
istream
。稍后,在页面下方的示例旁边有一条注释:

ifstream ist(name.c_str()); // ist is an input stream for the file named name.

我有点困惑,
ifstream
ist()
ist
之间的区别是您将要使用的
ifstream
的实例。有一种类型-
ifstream
,它可以是许多变量的类型

您可以有
ist
ist2
ist3
xpto
,它们都是
ifstream


ifstream
是类型。

ifstream
是类型,
ist
是变量名。这是非常基本的东西。
std::ifstream
是一个类,
ist
是该类的一个实例。我认为ist是变量名。但他们的措辞让人觉得你必须使用ist,我也见过很多其他人使用它。这只是使用它的惯例吗?@UnworthyToast我想说它只是“输入流”的缩写@UnworthyToast我个人从未见过
ist
作为文件流的变量名。您可以随意使用,但我建议您选择易于理解和简洁表达意图的变量名。