Skip to content
Permalink
a107f175d6
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
40 lines (24 sloc) 2.15 KB

DATA TYPES

One of the quintessential aspect of a Programming Language are its Data Types that it provides. These are important to learn, especially in C++ because, while they might look the same, they all serve widely different purposes.

Let's begin by looking at the following screenshot:

image

Through this, I have defined two structs that will act as the basis of the type of data type you can include; fixed data types and non-fixed.

Fixed data types are those of which that have a signed integer type associated iwth them with the width that corresponds with the bit count ranging from 8 to 64. Typically speaking, these data types are much faster compared to the non-fixed counterparts due to the lack of lease in their data range

For example, data types that start with u typically have a range of 0 to 255. The u is a declarative that tells the compiler that in the bit count range, the constant 1 is used as the unsigned integer type.

Whereas, int_t is a surrogate of uint_t because it's data range is much more vast at the expense of a longer compilation time, (the range being -128, 127)

Another viable method of declaring data types and variables is through macros. C Macros are powerful because you are able to declare them like you would with any other variable except with the added benefit of one-liners in order to make your code cleaner.

image

image

END RESULT:

Hello Harry

NOTE:

It should be noted that while you can make the declrative of a macro anything such as an int, char, string, bool, double, float, const, etc You CANNOT define a macro as a struct otherwise it will not work

By all means, you can do what I did in the first screenshot and define a macro with the same name as the struct but it needs to explictially state that it is a struct otherwise it will not work for some reason?!