It's probably because you haven't included using std namespace; before using the string data type, or you should use std::string in place of string. Either option will get you the same results, but the latter does not require using std namespace be defined first.