Am trying to open a file by calling a function.
Error: [Linker error] undefined reference to `readinfo()'
The code:
#include<iostream>
#include<fstream>
#include<string>
//#include "cabin.h"
using namespace std;
string readinfo();
int main ()
{
string cabins;
cout << readinfo();
system ("pause");
return 0;
}
//defining fuunction read info
string readinfo(string a)
{
string line;
a = line;
ifstream myfile("cabinsConfig.txt");
if (myfile.is_open())
{
while(! myfile.eof())
{
getline (myfile,line);
cout << line;
cout << endl;
}
myfile.close();
} else cout << "failed opening";
//return myfile;
}
The declaration of readinfo() takes no parameters, and the definition takes an std::string.