C++ Type Modifiers

Introduction

C++ types can have modifiers.

Some of the modifiers are signed and unsigned.

The signed (the default if omitted) means the type can hold both positive and negative values.

The unsigned means the type has unsigned representation.

Other modifiers are for the size:

  • short - type will have the width of at least 16 bits, and
  • long - type will have the width of at least 32 bits.

We can now combine these modifiers:

#include <iostream> 

int main() /*  w w  w.j  av a 2s  .co m*/
{ 
    unsigned long int x = 4294967295; 
    std::cout << "The value of an unsigned long integer variable is: " << x; 
} 

Type int is signed by default.




PreviousNext

Related