search
  • Sign In
  • Sign Up
Password reset successful

Follow the proiects vou are interested in andi aet the latestnews about them taster

C++ modifier types

Collection 154
Read 53378
update time 2016-09-11

C++ allows modifiers to be placed before the char, int, and double data types. Modifiers are used to change the meaning of a basic type so it better meets the needs of various situations.

The data type modifiers are listed below:

  • signed

  • unsigned

  • long

  • short

Modifierssigned, unsigned, long and short can be applied to integers, signed and unsigned can be applied to character types, and long can be applied to double types. The

modifiers signed and unsigned can also be used as prefixes for the long or short modifiers. For example: unsigned long int.

C++ allows the use of shorthand notation to declare unsigned short or unsigned long. Instead of int, you can write the words unsigned, short or unsigned, long, int is implicit. For example, both statements below declare unsigned integer variables.

unsigned x;
unsigned int y;

In order to understand the difference between C++ interpretation of signed integer and unsigned integer modifiers, let’s run the following short program:

#include <iostream>
using namespace std;
 
/* 
 * 这个程序演示了有符号整数和无符号整数之间的差别
*/
int main()
{
   short int i;           // 有符号短整数
   short unsigned int j;  // 无符号短整数

   j = 50000;

   i = j;
   cout << i << " " << j;

   return 0;
}

When the above program is run, it will be output The following results:

-15536 50000

In the above results, the bit pattern of the unsigned short integer 50,000 is interpreted as the signed short integer -15,536.

Type qualifiers in C++

Type qualifiers provide additional information about variables.

QualifierMeaning
constconst Objects of type cannot be modified during program execution.
volatileModifier volatile Tells the compiler that the value of a variable may be changed in ways not explicitly specified by the program.
restrictA pointer decorated with restrict is the only way to access the object it points to. Only C99 added the new type qualifier restrict.
Hot AI Tools
Undress AI Tool
Undress AI Tool

Undress images for free

AI Clothes Remover
AI Clothes Remover

Online AI tool for removing clothes from photos.

Undresser.AI Undress
Undresser.AI Undress

AI-powered app for creating realistic nude photos

ArtGPT
ArtGPT

AI image generator for creative art from text prompts.

Stock Market GPT
Stock Market GPT

AI powered investment research for smarter decisions

Popular tool
Notepad++7.3.1
Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version
SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1
Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6
Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version
SublimeText3 Mac version

God-level code editing software (SublimeText3)