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
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:
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)
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.
Read and try the following program:
using namespace std;
unsigned short int myIdent = 7;
cout << myIdent;
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.
Related CoursesC++ Course
Relational Database and Sybase
Windows User Interface
Computer Programmer – A Jack of all Trade – Poem