Let\'s take the following code:
#include // std::string
using namespace std;
int main() {
//const::int i = 42; -> Error: \"expected
It compiles because
using namespace std;
pulls the entire std
namespace into the global namespace, so ::string
is the same as std::string
. Your line in question is actually interpreted as
const ::string str = "Foo";
However, int
is a keyword (and a fundamental type), and not a user-defined name that resides in any namespace. So ::int
doesn't make sense.