Is there an equivalent of type var in C ++?

So, I know that C ++ is strongly typed, and it was just interesting if there was any library (or any thing for this fact) that would allow you to create a variable that does not have an initial concrete type like var in Python .

+3
source share
3 answers

Take a look at boost::anyand boost::variant.

+9
source

Two main things come to mind:

+1
source

++ 11 auto, , . , :

auto index = 1; // index is inferred to be int
auto c = 'a' // c is inferred to be a char
0

Source: https://habr.com/ru/post/1746716/


All Articles