cout, cin, and string belong to the
std namespace, so instead of just writing cout, cin, or string, you're supposed to write std::cout, std::cin, and std::string e.g.,
Code:
#include <iostream>
#include <string>
int main()
{
std::cout << "Please enter your name:\n";
std::string first_name;
std::cin >> first_name;
std::cout << "Hello" << first_name << "!\n";
return 0;
}
Notice that I placed the #include <string> for std::string. I also indented the code properly and removed blank lines that do not contribute to readability.
Because all three names are from the std namespace, you could also use a
using directive within a local scope to bring them into scope and hence be able to use them without qualifying them with the namespace name, e.g.,
Code:
#include <iostream>
#include <string>
int main()
{
using namespace std;
cout << "Please enter your name:\n";
string first_name;
cin >> first_name;
cout << "Hello" << first_name << "!\n";
return 0;
}