为什么file1没有报错,file2和file3调用函数时显示未定义标识符?
#include<iostream>
using namespace std;
#include<fstream>
#include<cctype>
#include<stdlib.h>
int main()
{
fstream file1, file2,file3;//定义文件流对象
file1.open("file1.txt",ios::in);//打开文件1
if (!file1)//文件1打开检查
{
cout << "File1 open error!" << endl;
exit(0);
}
file2.open("file2.txt", ios::in);//打开文件2
if (!file2)//文件2打开检查
{
cout << "File2 open error!" << endl;
exit(0);
}
file3.open("file3.txt", ios::in);//打开文件3
if (!file3)//文件2打开检查
{
cout << "File3 open error!" << endl;
exit(0);
}
}