Class

  • + 1 comment

    This is a namespace issue. Both <string> and Student have a function called to_string. The compiler doesn't have enough information to determine which one you're trying to call. When you prefix the function with std::, you're specifying that it's the to_string that exists in the std namespace.

    All of the C++ challenges I've seen on this site have using namespace std at the top, which a lot of people consider to be bad practice. That statement allows you to call functions in the std namespace without the prefix std::. This problem shows why that blanket using statement can be troublesome. I recommend not including using namespace std at the top of your files. If you always explicitly qualify std functions with std::, you (and others using your code!) won't run into this issue.