Menu

C++ TUTORIALS - C++ Modifier Types

C++ Modifier Types

ADVERTISEMENTS

Type Qualifiers in C++

QualifierMeaning
constObjects of type const cannot be changed by your program during execution
volatileThe modifier volatile tells the compiler that a variable's value may be changed in ways not explicitly specified by the program.
restrictA pointer qualified by restrict is initially the only means by which the object it points to can be accessed. Only C99 adds a new type qualifier called restrict.

ADVERTISEMENTS

unsigned x;
unsigned int y;

ADVERTISEMENTS

#include <iostream>
using namespace std;
 
/* This program shows the difference between
 * signed and unsigned integers.
*/
int main()
{
   short int i;           // a signed short integer
   short unsigned int j;  // an unsigned short integer

   j = 50000;

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

   return 0;
}

-15536 50000