After using c-strings / character arrays for a year now I'm being encouraged to use the string type instead. After getting some errors in a multi-file project where i passed strings, I checked textbooks, websites... still not working.
So I wrote a simple test program. But even that isn't working. I'm pulling my hair out trying to figure out what I'm doing wrong, because I know it's probably something really simple to fix.
using namespace only applies to the source where it is used. Although my personal recommendation is that you pretend it doesn't exist and just write the whole type (std::string).
When using string type you have always to use either usingnamespace std; or explicit notation std::string because string type is a member of std namespace.
You have used using namespace std; only in your main.cpp file so this would compile whilst foo.cpp wouldn't.
In header files (foo.h) is generally better to use the explicit notation std::string because in some cases you don't want to use using namespace std; in all files which #include your header file.