Wu Yuxiong - born natural C ++ language study notes: C ++ type modifiers

C ++ allows the char , int and double placing modifiers before data type. Modifier is used to alter the basic types of meaning, so it's better meet the needs of a variety of scenarios. 
The following lists the data type modifier: 
Signed 
unsigned 
Long 
short 
modifier Signed, unsigned, Long and short applicable integer, signed and unsigned char can be applied, Long may be applied to double. 
Modifiers signed and unsigned may be as long or short prefix modifiers. For example: unsigned Long  int . 
C ++ allows shorthand notation to declare an unsigned short integer, or unsigned long integer. Can not write int , just write the word unsigned, Short or unsigned, Long , int  is implied. For example, the following two statements both declare unsigned integer variables.
unsigned the X-; 
unsignedint y;
#include <the iostream>
 the using  namespace STD; 
 
/ *  
 * This program demonstrates the difference between the signed integer and an unsigned integer with a 
* / 
int main () 
{ 
   Short  int I;            // signed short integer 
   Short unsigned int J;   / / unsigned short integer 
 
   J = 50000 ; 
 
   I = J; 
   COUT << I << "  " << J; 
 
   return  0 ; 
} 
when the above procedure is run, the following output results:
 - 15536  50000 
above results, unsigned short integer 50 , 000The bit pattern is interpreted as a signed short integer - 15 , 536 .
C ++ The type qualifier 
type-qualifier provides additional information variables. 
const     const object types can not be modified during program execution.
volatile     qualifier volatile tells the compiler does not need to optimize volatile variable declarations, so that the program can be read directly from memory variables. For optimized compilers will generally variable variables, the variables in memory to speed up the values in a register write efficiency. 
restrict restrict modified by the pointer is the only access to the object it points the way. Only C99 adds a new type qualifier restrict.

 

Guess you like

Origin www.cnblogs.com/tszr/p/12142890.html