Skip to content

Data Types

Artemis edited this page May 12, 2023 · 2 revisions

C++ 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.

Built-in Data Types

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

Integral types are used to represent whole numbers. Examples include int, short, and long.

Floating Point Types

Floating point types are used to represent numbers with fractions. Examples include float and double.

Character Types

Character types are used to store characters, such as letters, numbers, and symbols. The most commonly used character type is char.

Boolean Types

Boolean types are used to represent true or false values. The most commonly used boolean type is bool.

User-Defined Data Types

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.

Summary

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.

Clone this wiki locally