Close
Close

what is a namespace in c++?

   Shreyoshi


Answers

  •   

    A namespace can be defined in several parts and so a namespace is made up of the sum of its separately defined parts. The separate parts of a namespace can be spread over multiple files.

    So, if one part of the namespace requires a name defined in another file, that name must still be declared. Writing a following namespace definition either defines a new namespace or adds new elements to an existing one −

    namespace namespace_name {
       // code declarations
    }

    All the files in the C++ standard library declare all of its entities within the std namespace. That is why we have generally included the using namespace std; statement in all programs that used any entity defined in iostream.



  •   

    I have answered this question here



Ask Yours
Post Yours
Write your answer