Data Types in C++
Data Types in C++ define the type of data a variable can hold, for example an integer variable can hold integer data, a character type variable can hold character data etc.
Data types in C++ are categorized in three groups: Built-in, user-defined and Derived.
Built in data types:
char: For characters. Size 1 byte.
char ch = 'A';
int: For integers. Size 2 bytes.
int num = 100;
float: For single precision floating point. Size 4 bytes.
float num = 123.78987;
double: For double precision floating point. Size 8 bytes.
double num = 10098.98899;
bool: For booleans, true or false.
bool b = true;
wchar_t: Wide Character. This should be avoided because its size is implementation defined and not reliable.
User-defined data types:
We have three types of user-defined in C++
1. struct
2. union
3. enum
I have covered them in detail in separate tutorials. For now just remember that these comes under user-defined data types.
Derived data types:
We have three types of derived-defined data types-
1. Array
2. Function
3. Pointer
They are wide topics of C++ and I have covered them in separate tutorials. Just follow the related post and you would be fine.
Related Posts:
- Operators in C++
- Recursion in C++ with example
- Functions in C++ with example
- goto statement in C++ with example
- Break statement in C++ with example
- Continue Statement in C++ with example
- do-while loop in C++ with example
- While loop in C++ with example
- For loop in C++ with example
- Switch Case statement in C++ with example
- If else Statement in C++
- Constructors in C++
- Enumeration in C++
- OOPs Concepts in C++
- this pointer in C++
- Pointers in C++
- Strings in C++
- Passing Array to Function in C++
- Multidimensional Arrays in C++
- Arrays in C++
- Difference between Function Overloading and Function overriding in C++
- Function Overriding in C++ with examples
- Function overloading in C++ with examples
- Polymorphism in C++ and its types
- Inheritance in C++ with examples
- Destructors in C++ with examples
- Encapsulation in C++ with example
- Friend Class and Friend Functions in C++
- Interfaces in C++ with Examples
- Abstraction in C++ with example