-
-
Notifications
You must be signed in to change notification settings - Fork 1
Data Types
C++ is a statically typed language, which means that all variables must be explicitly declared with a data type before they can be used. Data types tell the compiler what kind of data a variable is going to store.
C++ provides a variety of built-in data types that are used to represent the basic types of data. The following data types are available in C++:
Integral types are used to represent whole numbers. Examples include int
, short
, and long
.
Floating point types are used to represent numbers with fractions. Examples include float
and double
.
Character types are used to store characters, such as letters, numbers, and symbols. The most commonly used character type is char
.
Boolean types are used to represent true or false values. The most commonly used boolean type is bool
.
C++ also allows users to define their own data types. This is done using the typedef
keyword, which allows users to create an alias for an existing data type. For example:
typedef int Age;
This statement defines a new data type called Age
, which is an alias for the int
data type.
C++ is a statically typed language, which means that all variables must be declared with a data type before they can be used. C++ provides a variety of built-in data types, including integral types, floating point types, character types, and boolean types. Additionally, users can define their own data types using the typedef
keyword.