I'm attempting to create a class to open a file, and read from it, by passing the filename to the constructor. I have searched the web and have tried to replicate the pertinent examples. I have managed to reduce the compiler (g++) errors to the following:
/tmp/ccBDeLHM.o: In function `main':
main.cpp:(.text+0x6a): undefined reference to `myFiles::myFiles(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
collect2: ld returned 1 exit status
If you are using an IDE, make sure myFiles.cpp is added as part of your project. When you do a rebuild, you should see it compiling. If you don't see it compiling then you know it's not part of your project.
If you aren't using an IDE -- get one. It will make your life 100x easier. To do it without an IDE you have to give the commandline some weird option thing. I don't really know how to do it by hand in g++.
Also, in the constructor myFiles::myFiles(std::string fileName)
The line passFile.open(fileName); will not work because for historical reasons the open method takes a C style string and not a std::string. Change it to: