Broad Network


Simple Type Specifiers in C++

Specifiers in C++ - Part 1

Forward: In this part of the series I explain the meaning of type specifiers in C++.

By: Chrysanthus Date Published: 25 Aug 2012

Introduction

This is part 1 of my series, Specifiers in C++. In this part of the series I explain the meaning of type specifiers in C++. A specifier is a reserved word that can be placed in front of an identifier to give the object or function identified, a special meaning. The word, identifier, here refers to the name of an object or the name of a function.

Prerequisite
This series is part of my Advanced Topics in C++. So, you most have completed the professional phase of my C++ Tutorials volume, and some of the advanced topics, before reaching here.

Precisely, you should have covered the series whose first part begins with:

- Automatic and Dynamic Storage Duration in C++

To arrive at this series, just type this title and my name, Chrys, in the search box of this page and click the Search Button. When you go to the series, it will tell you that you should have covered other previous series.

There is no problem, if you have got the prerequisite knowledge from elsewhere.

List of Simple Type Specifiers
The following is a list of simple type specifiers:

char
unsigned char
signed char
bool
unsigned int (unsigned)
signed int (int or signed)
unsigned short int (unsigned short)
unsigned long int (unsigned long)
signed long int (signed long)
long int (long)
signed short int (signed short)
short int (short)
wchar_t
float
double
long
void

In the list, what is in brackets is a short form or synonym of what is on the left in the line. That is: “unsigned int” and “unsigned” are the same; “signed int” and “int” are the same; “signed int” and “signed” are the same; “unsigned short int” and “unsigned short” are the same; “unsigned long int” and “unsigned long” are the same; “signed long int” and “signed long” are the same; “long int” and “long” are the same; “signed short int” and “signed short” are the same; and “short int” and “short” are the same.

You should be familiar with these simple type pacifiers. The thing to learn here is, that some specifiers are a combination of others. Now each combination or a single specifier from this list, is considered as one specifier.

Example
Read and try the following program:

#include <iostream>
using namespace std;

int main()
    {

        unsigned short int myIdent = 7;

        cout << myIdent;
    
        return 0;
    }

The simple specifier in this code is, “unsigned short int”. Here, unsigned, means that the object can have only positive values, with or without the positive (+) sign. So, in the code, if you replace 7 with –7, the program will not work. In the specifier, short, means that the value has to be of small size (magnitude). The word, magnitude, means size of a number, ignoring its positive (+) or negative (+) sign. In the specifier, int, means that the value has to be an integer.

You should already be familiar with these simple object type specifiers. What you should learn in this part of the series is, that a combination of simple type specifiers is still considered as one specifier. You should also learn the synonyms of the specifiers.

That is it for this part of the series. We stop here and continue in the next part.

Chrys

Related Courses

C++ Course
Relational Database and Sybase
Windows User Interface
Computer Programmer – A Jack of all Trade – Poem
NEXT

Comments

Become the Writer's Fan
Send the Writer a Message