c++ - namespace usage -


I am trying to start using the namespace correctly (or at least the best) way.

The first thing I tried to do was to avoid using namespace XXX; Instead of initializing my files, I want to use xxx :: yyy as locally possible.

Here is a small program that shows:

  #include  

If I'm std :: cout; I leave the lines using or std :: endl , then the compiler will complain when I use cout or endl Trying to do

But why is it not necessary for srand , rand and time ? I am pretty sure that they are in std , because if I want to specifically put std :: in front of them, then my code is working fine.

If you use cstdlib et al, the names in them are kept in both global and std :: namespaces So that you can select them prefixed with std :: or no. It is seen by some as an attribute, and is seen as a wrong practice by others.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -