Because string
is defined within namespace called std
.
you can write std::string
everywhere where
is included but you can add using std::string
and don't use namespace in the scope (so std::string
might be reffered to as string
). You can place it for example inside the function and then it applies only to that function:
#include
void foo() {
using std::string;
string a; //OK
}
void bar() {
std::string b; //OK
string c; //ERROR: identifier "string" is undefined
}