Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is C++ still considered as a statically typed language? [duplicate]

Tags:

c++

c++11

I used to know that C++ is a statically typed language, but the newer C++ specification introduces a newer syntax auto which can determine the variable type by itself. So can C++ still be considered as a statically typed language?

like image 214
rcs Avatar asked Nov 28 '22 20:11

rcs


2 Answers

No, this does not make C++ a dynamically typed language. auto is just a compile-time type inference method. The resulting code is exactly the same as without auto and the type cannot change at run-time.

like image 183
Sami Kuhmonen Avatar answered Dec 05 '22 09:12

Sami Kuhmonen


C++ is still a statically typed language with the auto type specifier because auto denotes that the type will be inferred by the compiler at compile time. Rather then at run time in dynamically typed languages.

like image 23
TylerM2320 Avatar answered Dec 05 '22 09:12

TylerM2320