C++ Basic Object Types
C++ Taking the Bull by the Horns – Part 3
Forward: In this part of the series, we look at the basics of what is called object types in C++.
By: Chrysanthus Date Published: 21 Aug 2012
Introduction
Note: If you cannot see the code or if you think anything is missing (broken link, image absent), just contact me at forchatrans@yahoo.com. That is, contact me for the slightest problem you have about what you are reading.
Object
The computer memory is a series of cells, and each cell can store one character. We say each cell can store a byte. In this part of the tutorial series, I give you the fundamental objects of C++. Any number such as 538, stored in memory is called a datum. The plural of datum is data. Data are of different forms, not just numbers. A datum is stored in memory in a short series of consecutive cells. An object is the region (small group of consecutive cells) in memory holding a datum. In this part of the series we look at the basics of different values that an object can hold.
The cells of the computer memory are numbered numerically. These numbers are called memory addresses. We shall not use memory addresses in these tutorials, but it is good for you to know that they exist. We shall use them indirectly.
int
An integer abbreviated, int in C++ can be the value of an object. In other words the value (content) of an object can be of type Integer. An integer is a whole number, e.g. 6987 or -6987. There are classifications of the integer, but I will not go into that in this series.
float
In C++ a float is a number with a decimal point, e.g. 45.36. There are several ways of writing floats in C++ but I will not go into that in this basic tutorial series. I have talked about float in general terms. There are three classifications of float in C++, but I will not go into that in this basic tutorial series. The value of an object can be a float.
Character abbreviated, char in C is a character, e.g. A, a, B, b, 1, 3, 5, etc. The value of an object can be a character. Such an object is one byte long, and will be stored in just one cell in memory. Whenever, we talk about the char object type, we are talking about only one single character.
bool
There is something called, Boolean. In life a Boolean value is either true or false. In C++, true is the number, 1 and false is the number, 0. An object can hold a Boolean type, which is 1 or 0. In C++, Boolean is written as, bool.
void
When the type of datum in an object is said to be void, it means that the region of the object is empty. This empty region is not reserved for an int, float, or any of the other object types.
Derived types
In C++ there are certain types of objects that are called derived types. A derived object type is a combination of two or more fundamental types of object. One example of the derived object type is called, enumeration. Another example is called the pointer. There are other derived object types, some of which we shall see as we go along. An object can also hold a derived object content. In other words, a region in memory can hold a derived object.
enum
An enumeration abbreviated, enum in C++ is a set of integers. In that set, each integer has a name. We shall see an example in the next part of the series.
Let us end here for this part of the series. This is important: Do not add or subtract in your mind, any idea to what I have given you in this part of the series and in the rest of the series. In order for you to do that you would have to liken what I give you to the human language (English) or mathematics. I believe doing that would be misleading and you would not find the study of C++ easy. We continue in the next part of the series.
Chrys
Related Courses
C++ CourseRelational Database and Sybase
Windows User Interface
Computer Programmer – A Jack of all Trade – Poem
NEXT