C + + notes-namespaces and exceptions

Source: Internet
Author: User

  • Name space
    • member functions can be declared in the definition of a namespace and then used in a defined way such as: Namespace__name::member_name to define this member function
        •     
          1 namespaceparser{2     DoublePrimBOOL);3     DoubleTermBOOL);4 }5 6 DoubleParser::p rim (BOOL Get){/*definition*/}7 DoubleParser::term (BOOL Get){/*definitions, defined in the definition of a namespace*/}
    • The scope of the name in the namespace and the qualifier of the namespace are also necessary, and this is somewhat similar to the class. Qualifiers are the form of namespace_name::member_name.
        • How to use declarative qualifiers: Using namespaces:: Names. Can not write namespaces in subsequent calls:: Name.
    • namespaces:
      •   is actually a memory area named by the program designer, and the programmer can specify a number of namespaces as needed, placing some global entities in each namespace, separating them from other global entities
      • Role: It is to create some separate scopes, separating some global entities from each other .
        • < Span style= "FONT-SIZE:18PX;" >
           namespace   NSL { Span style= "color: #0000ff;" >const  int  rate=0.08 ; //  constant  doublepay //  variable  doubletax () //  function  {return  a*rate;} namespacens2  //       nested namespaces 
           {int   Age;}}  
    • Using namespaces
  • Exception: Next blog post reproduced

C + + notes-namespaces and exceptions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.