Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Constant | Variables
Introduction to C++ | Mobile-Friendly

bookConstant

If you have a static variable that never changes and you want that nobody overrides your variable, use the const keyword by declaration. It makes the variable unchangable (constsant).

For example:

const double x = 42;

The variable x will always be 42 and nobody can change it. The following code would cause an error:

const int x = 10;
x = 15;

You should declare variables as constants if you are sure that they will probably never change:

const int monthPerYear = 12;
const char firstAlphabetLetter = 'A';
question-icon

Define the variable secondsPerMinute as the const variable:

;

Click or drag`n`drop items and fill in the blanks

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 8

Pregunte a AI

expand

Pregunte a AI

ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

Suggested prompts:

Pregunte me preguntas sobre este tema

Resumir este capítulo

Mostrar ejemplos del mundo real

Awesome!

Completion rate improved to 3.7

bookConstant

Desliza para mostrar el menú

If you have a static variable that never changes and you want that nobody overrides your variable, use the const keyword by declaration. It makes the variable unchangable (constsant).

For example:

const double x = 42;

The variable x will always be 42 and nobody can change it. The following code would cause an error:

const int x = 10;
x = 15;

You should declare variables as constants if you are sure that they will probably never change:

const int monthPerYear = 12;
const char firstAlphabetLetter = 'A';
question-icon

Define the variable secondsPerMinute as the const variable:

;

Click or drag`n`drop items and fill in the blanks

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 2. Capítulo 8
some-alt