There's two dimensions when it comes to typing in a language.
- First one is the weak vs. strong dimension.
- Second one is the static vs. dynamic dimension.
Weak vs. strong, in my understanding, is how specific a type needs to be, and how easily it can be implicitly converted or used as another type. For example, a string is different than an int. If you have a function that takes in a string, you can't pass it an int. On the other hand, a double also is not an int, but if you pass an int into a function expecting a double, it will be implicitly converted into a double, so this is "weaker" in a sense. A void* (void pointer) is about the weakest type in C++, because it can point to basically any other type of object.
error: could not convert 'a' from 'int' to 'std::string {aka std::basic_string<char>}' |
Static vs. dynamic is about whether or not types are known at compile-time.
C++ is a static language, because all objects have a particular type at compile-time. You can't change the
same object from a Foo to a Bar at run-time. However, parts of C++ have
weak typing, because when you see an object of type void*, you don't actually know what the object it points to is.