C + + Note fourth--types and declarations

Source: Internet
Author: User

  1. Boolean quantity
      1. Eg:bool b1=a==b;//This example, = is the assignment, = = is the judgment is equal, so first judge whether equal, a if equal to the value of B,B1 is true, otherwise it is false
      2. BOOL is often used as the result type of a function that checks whether certain conditions are true,
        1. Eg:bool Greater (int a,int b) {return a>b}
      3. BOOL can be implicitly converted to integers (any nonzero integer is true, 0 is false)
        1. Eg:bool a=ture;
        2. BOOL B=true;
        3. BOOL x=a+b;//Because a+b=2 is true, so X is also Tru
        4. Bool y=a|b;//a/b=1, so y is true
  2. Character type
    1. A char type contains 8-bit bits number that can hold different values in 256
  3. Integer type
  4. Floating point Type
  5. Big
    1. sizeof (char) = 1
    2. sizeof (short) = 2
    3. sizeof (float) = 2
    4. sizeof (int) = 4
    5. sizeof (double) = 8
    6. sizeof (void*) = 4
    7. sizeof (LONG) = 4
    8. sizeof (Longlong) = 8
    9. sizeof (BOOL) =
    10. sizeof (wchar_t) = 2
  6. Void
    1. Used to characterize a function void f () that does not return a merit;
    2. The underlying type used as a pointer to an object of unknown type, which allows the pointer to be cast to any type of void * PV;
    3. A special example:
      1. Pointer to type char:
        1. Char c= ' V ';
        2. cout<<c<<endl;
        3. Cout<<&c<<endl;//char type of data, the output address is not used & symbol
        4. cout<< (void *) c<<endl;//can be output using the (void*) pointer, which can also be coerced into other types of pointers
        5. cout<< (double *) C<<endl
        6. return 0;
  7. Enumeration
  8. Statement
    1. In addition to functions and namespaces, other declarations should end with semicolons
    2. Name of the statement
      1. The best name to get a comparative standard, easy to read. Eg:current_token
      2. Scope of the name:
        1. It is generally starting from the place where the name declaration begins to the place where the function block ends to become the scope of the name
        1. If a global variable and a local variable are the same name, the global variable is obscured locally, and if you want to call a global variable, you can do so through the scope resolution operator:: Make the call.
    3. Initialization of the Declaration
      1. If not initialized: Global, namespace, local static objects are initialized to the corresponding 0
      2. However, local objects and dynamic objects are not initialized;
        1. For example:
          1. Int Main () {
            1. Int x;//Here is the dynamic variable, no initial
          2. }
  9. Typedef
    1. You can change a name to another name: typedef unsign CHAR uchar;//unsign char with a long name into the Uchar type

C + + Note fourth--types and declarations

Related Article

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.