Contenido del Curso
Introducción a C++
Introducción a C++
Tipos de Datos
Al declarar una variable, necesitas especificar qué tipo de datos almacenaremos en ella. Existen tipos de datos para un manejo fácil de la memoria en cada situación.
Data Type |
int |
short |
float |
double |
char |
bool |
void |
Numerical
These types are essential for storing numerical values and manipulating numeric data. We can split them into two groups: integers and decimals.
integers
decimals
// examples of literal integers 5 100 30
Bool
El tipo de dato bool
representa dos valores booleanos: cero interpretado como falso y uno es interpretado como verdadero.
Char
The char
data type is used to store individual characters, which can include letters, digits, punctuation marks, and special characters.
Void
The void
data type represents the absence of a value. It is primarily used for functions that do not return any data. When a function is declared as void
, it means the function performs an action but does not provide a result.
Note
The use and purpose of
void
will be explored further in the chapter about functions.
You can check the data type of certain expressions using the code below. Feel free to experiment with it.
main
#include <iostream> #include <typeinfo> // Provides tools for type identification int main() { // `typeid().name()` gives you the type of expression // Replace `___` with a number, boolean (true/false), or character std::cout << "The data type is " << typeid(___).name() << std::endl; }
¡Gracias por tus comentarios!