probably you are not including all the headers - I have no problem compiling the following code:
Code:
#include <iostream>
#include <string>
#include <fstream>

void openFile(std::ifstream& file)
{
	file.clear();
	for(;;)
	{
		std::string fileName;
		std::cout << "Enter the name of your file: " << std::endl;
		std::cin >> fileName;
		file.open(fileName.c_str());
		if (file.good())
		{
			break;
		}
		std::cerr << "\nThere is no file, named --> " << fileName << " <-- in your folder.\n\n" << std::endl;
		file.clear();
	}
}

int main()
{
	std::ifstream f;
	openFile(f);
	return 0;
}