test.h:
Expand|Select|Wrap|Line Numbers
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- class ReadFile
- {
- public:
- //Constructor
- ReadFile(string file_path = "\0") : text_file (file_path.c_str())
- {
- count = 0;
- };
- //Destructor
- ~ReadFile()
- {
- text_file.close();
- };
- long count;
- string line();
- bool end_of_file();
- protected:
- ifstream text_file;
- string next_line;
- };
Expand|Select|Wrap|Line Numbers
- #include "test.h"
- using namespace std;
- string ReadFile::line()
- {
- if (! text_file.eof())
- {
- count += 1;
- }
- ifstream::getline(text_file,next_line); // Get a line from the text file
- return next_line;
- }
- bool ReadFile::end_of_file()
- {
- return text_file.eof(); // Check if it's the end of the file
- }
------ Build started: Project: clr_project, Configuration: Debug Win32 ------
Compiling...
test.cpp
.\test.cpp(13) : error C2665: 'std::basic_istream<_Elem,_Traits>::getline' : none of the 2 overloads could convert all the argument types
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
C:\Program Files\Microsoft Visual Studio 9.0\VC\include\istream(593): could be 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::getline(_El em *,std::streamsize)'
with
[
_Elem=char,
_Traits=std::char_traits<char>
]
while trying to match the argument list '(std::ifstream, std::string)'
Build log was saved at "file://c:\Documents and Settings\User\Desktop\clr_project\clr_project\Debu g\BuildLog.htm"
clr_project - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========