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
作为文件流的变量名。您可以随意使用,但我建议您选择易于理解和简洁表达意图的变量名。