Literal literals in C + + specify a type

Source: Internet
Author: User
Tags one more line

Only built-in types exist in C + +, and there is no class-type literal value.
For example: 0 is the literal value of type int, and 3.14159 is a type literal of double.

Many types of literal literals

integer floating-point literals                   //decimal    decimal 024     &NBSP ;            // octal      octal 0x14         &NBSP ;      //  hexadecimal      hex 128u, 128U        //&nbs P;  unsigned1024ul              //   unsigned long1l                    //     long   Long plastic 8Lu   & nbsp              //     unsigned long3.14159f = 3.14159e0f &nb sp;//float  , scientific count. 001f  = 1e-3f  //float, scientific count 12.345L = 1.2345e1l  //long double   extended precision , Science counts 0.  = 0e0  //Double, scientific count ' a '//char      character l ' a '  //wch ar_t &Nbsp;  wide characters//no literal constants for short    string LiteralsString literals are a string of constant characters, string literal constants are enclosed in double quotation marks, and character literal constants are enclosed in single quotation marks. In order to be compatible with the C language, string literals in C + + will be automatically added by the compiler to an empty string at the end.: ' A ': Represents a single character a "a": a string representing a character A and a null character two characters similarly there is a wide string L "a wide string literal": A string of wide characters + wide-empty character strings literal connection different types of strings cannot be concatenated: string literals and wide string literals cannot be concatenatedStd::cout << "a multi-line"                       "string literal"                       "using concatenation"                      << Std::endl: A multi-line string literal using concatenation but std::cout << "multi-line"    & Nbsp;                 l " Literal "<<std::endl; will compile the error. In addition, there is one more line literal: Std::cout <<" A multi-line \string literal \using concatenation "& lt;< Std::endl; note that "\" must be at the end of the line, followed by No comments or spaces   ------------------------------------------------------ -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------

Literal literals in C + + specify a type

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.