C++ Data types
1. Enumerated Data type( click here to Learn)
2. Structure and classes( click here to Learn)
3. Array( click here to Learn)
4. Function( click here to Learn)
5. Pointers( click here to Learn)
6. References( click here to Learn)
C language and c++ languages both support all the build-in data types. with the exception of void , and the basic data type may have several modifiers preceding them to serve the needs of various situation. The unsigned signed, short ,long and may be applied to character and integer(or use with character or integer) basic data types. However, the modifier long may also be applied to double. and Data type represent is machine specific in c++ programming.
In the below table show list all combinations of the basic data data types and modifiers along with their size and range for a 16 bit machine.
|
1 |
-128 to 127 |
|
1 |
0 to 255 |
|
1 |
-128 to 127 |
|
2 |
-32768 to 32767 |
|
2 |
0 to 65535 |
|
2 |
-31768 to 32767 |
|
2 |
-31768 to 32767 |
|
2 |
0 to 65535 |
|
2 |
-31768 to 32767 |
|
4 |
-2147483648 to 2147483647 |
|
4 |
-2147483648 to 2147483647 |
|
4 |
0 to 4294967295 |
|
4 |
3.4E-38 to 3.4E+38 |
|
8 |
1.7E-308 to 1.7E+308 |
|
10 |
3.4E-4932 to 1.1E+4932 |
talk about void some the type void was introduced in ANSI C Language. two normal uses of void are
1. To specify the Return type of a function or from a function when it is not returning any value
2. To indicate an empty argument list or parameters to a function
example
function(void);
Another important use of void is in when the declaration of generic pointers, Example
*gp;
so A generic pointer can be assigned a pointer value of any basic data type, but also it may not be dereferenced , lets see in example
are valid statements ,but the invalid statements are
it is illegal, it would not make sense to dereference a pointer to a void value
Assigning any pointer type to a void pointer without using a cast is allowed in both c++ and C programming, we can also assign a void pointer to a non void pointer without using a cast to a non void pointer type.
but This is not allowed in c++ programming, for example
These statements are valid in ANSCII C but not in C++, so A void pointer cannot be directly assign to other type pointer in c++, then in this condition
we need to use a cast operator as shown below