C++ Data Types
Overview
Data types are the foundation of programming languages, defining the types of data variables can store and the operations that can be performed on this data. C++ provides rich built-in data types and also supports user-defined types.
🏗️ Data Type Classification
Data Type Hierarchy
mermaid
graph TD
A[C++ Data Types] --> B[Basic Types]
A --> C[Compound Types]
A --> D[User-defined Types]
B --> B1[Integer Types]
B --> B2[Floating Point Types]
B --> B3[Character Types]
B --> B4[Boolean Types]
B --> B5[Void Type]
C --> C1[Arrays]
C --> C2[Pointers]
C --> C3[References]
D --> D1[Structures]
D --> D2[Classes]
D --> D3[Enumerations]🔢 Integer Types
Basic Integer Types
cpp
#include <iostream>
#include <climits>
int main() {
// Basic integer types
short short_var = 32767;
int int_var = 2147483647;
long long_var = 2147483647L;
long long long_long_var = 9223372036854775807LL;
// Unsigned integer types
unsigned short ushort_var = 65535;
unsigned int uint_var = 4294967295U;
unsigned long ulong_var = 4294967295UL;
// Output type sizes and ranges