0
Data types and variables
If a variable is defined to be a particular data type, can the same variable be used for a different data type in the same program?
1 Respuesta
+ 1
That is not possible, C++ is a statically typed language, where the data types are fixed at compile time. However, unions and variants provide a way for a variable to be able to hold values of different types.
https://en.cppreference.com/w/cpp/language/union
https://en.cppreference.com/w/cpp/utility/variant