Hi, I am new to C++ coding and needed some help.I have written some c++ code in codeblocks but I am getting errors when i am trying to compile it. I have a file named files.txt and this file consists of the names of the files that actually contain the data that I need to present. I am trying to get the name of files from from once class and passing it through to another to process. These are the codes that i have:
The error message that i get is error: no match for call to (std:: string). For ther line with the error I have used (*******Error points to this line).
Thanks so much...
Code:
main.cpp
#include <iostream>
#include <fstream>
#include <string>
#include "Files.h"
#include "Datafile.h"
using namespace std;
int main()
{
ifstream infile("fileListAug.txt");
if(!infile) return -1;
Files F;
infile >> F;
ofstream ofile("2011-Aug.csv");
ofile << F;
return 0;
}
Code:
Files.cpp
#include "Files.h"
Files::Files()
{
}
Files::Files(const string m_filenames)
{
m_filename = m_filenames;
}
istream & operator >> (istream & input, Files & F)
{
do{
getline(input, F.m_filename, ';');
cout << F.m_filename << endl;
}while(! input.eof());
return input;
}
Code:
Datafile.cpp
#include "Datafile.h"
#include <iostream>
#include <fstream>
#include <string>
Datafile::Datafile()
{
}
Datafile::Datafile(const string m_lines)
{
m_line = m_lines;
}
void Datafile::GetDatafile()
{
ifstream infile;
infile.open(files.m_filename());//(*******Error points to this line)
Datafile L;
infile >> L;
ofstream ofile("2011-Aug.csv");
ofile << L;
}
istream & operator >> (istream & input, Datafile & L)
{
do{
getline(input, L.m_line, ';');
}while(! input.eof());
return input;
}
ostream & operator << (ostream & os, const Datafile & L)
{
cout << "!" << L.files << "!" << endl;
//os << L.lines << '\n';
return os;
}
Thanks so much...
Comment