class functions using a file

1
2
3
4
5
6
7
8
9
10
11
12
13
class firstt
{
public:
	firstt();
	void generation();//generates int array
	int charintconverter(string filename,int mid);//finds the middle integer
	void querysorted(string filename,int);// queries a random integer in sorted file
	void queryunsorted(string filename,int);//queries a random integer in unsorted file
private:
	void sorting();int number[5000];
	void formsortedfile(string filename, int number[]);//forms sorted file by putting int array in it with 'a' character between each integer
	void formunsortedfile(string filename,int number[]);//forms unsorted file by putting the same integer array in it
}


since I opened the sorted file in 'formsortedfile' function do I have to open it again in charintconverter function or is it enough to instantiate fstream object but how will the function understand which file to work on. Above charintconverter function gets filename as a parameter and opens it but I wondered if it is neccessary to open it every single time
Topic archived. No new replies allowed.