You need to define the std
. All C ++ standard library identifiers are defined in a namespace with that name. The namespace defines the scope of identifiers. You can determine directly when “Hello world” is displayed (this entry is called the direct identifier refinement):
std::cout << "Hello world" << std::endl;
There is also another way: you can write before the main()
function:
using namespace std;
This entry is used most often (for simplicity, in short listings). It means that after its execution all identifiers of the std
space are available as if they were declared globally. However, do not abuse this record, because in complex programs it can lead to periodic name conflicts, unpredictable consequences due to rules of overload.
Another option is to use a certain namespace. The example shows how to get a local opportunity to skip the prefix std::
for cout
and endl
:
using std::cout; using std::endl;