c++ error: referenced in function _main when reading a file -
c++ error: referenced in function _main when reading a file -
when i'm trying read file function
void readfile(string filename, string* anarray) { unsigned int linecounter = 0; ifstream infile = ifstream(filename); while (!infile.eof()) { string fileline; infile >> fileline; if (!fileline.empty()) { anarray[linecounter] = fileline; ++linecounter; } } infile.close(); }
i error below, assume because of pointer on string array ?
1>main.obj : error lnk2019: unresolved external symbol "void __cdecl resource::readfile(class std::basic_string,class std::allocator >,class std::basic_string,class std::allocator > *)" (?readfile@resource@@yaxv?$basic_string@du?$char_traits@d@std@@v?$allocator@d@2@@std@@pav23@@z) referenced in function _main
void readfile(string filename, string* anarray) {
this definition of fellow member function, forgot write class name.
void resource::readfile(string filename, string* anarray) {
as have now, you've defined new function in global namespace has nil resource
, when main
tries utilize resource::readfile
, definition cannot found.
c++
Comments
Post a Comment