for some reason c++ has a problem when i try to pass a string in as an argument to my method parseLine...
did i do it correctly ...thanks for any help.
parser.cpp---
parser.h---Code:#include <iostream> #include <fstream> #include <string.h> #include "parser.h" using namespace std; /* constructor */ parser::parser(void){ } /* reads in the specified file, line by line */ int parser::readFile(void) { string filename="data.txt"; string line; ifstream file(filename.c_str()); if(!file.is_open()) { cout << "Error...file is not opened" << endl; return 1; } while (!file.eof()) { /* get line by line */ getline(file, line); /* now parse the line */ parseLine(line); } file.close(); return 0; } void parser::parseLine(string line) { cout << "Parsing line: << line << endl; }
Code:#include <iostream> #include <string> class parser { public: parser(void); int readFile(void); void parseLine(string line); };



LinkBack URL
About LinkBacks


