Thursday, May 28, 2009

C++ Keyword using and a little on namespaces

std is a namespace for simple C++ functions. Two of these simple functions are cout and cin. But because they are part of the std namespace, C++ programmers are forced to type them as "std::cout" and "std::cin".

However, like most things in programing there is a way around typing std:: every time. The C++ keyword using allows us to declare that we are "using" a namespace, thus we do not have to repeatedly type said namespace. In other words; Put this in your global scope and you won't have to repeatedly type "std::" again and again:

using namespace std;

No comments:

Post a Comment