Что именно делает const_cast в C++? [дубликат]C++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 Что именно делает const_cast в C++? [дубликат]

Сообщение Anonymous »

Question:
I've been exploring different types of casting in C++, particularly const_cast, which is used to cast a const T to T, where T represents a data type. However, I encountered a perplexing behavior when experimenting with const_cast.

Consider the following code snippet:

#include int main() { const int32_t x = 2e8; // Attempt to modify a const variable using const_cast int32_t& y = const_cast(x); y = 20; std::cout

Источник: https://stackoverflow.com/questions/780 ... st-in-c-do
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»