Rolf Magnus wrote:
Vinodh Kumar P wrote:
Whenever I read any C++ literature I find the words "C++ is
statically type checked".OK.Agreed.
Is there any language that supports "Dynamic type checking"?
Most scripting languages do.
In such a case any type can be assigned to any other type during
compile time?
You variables might not even have a type at compile time since that
type can change at run-time. So if you assign a variable to another
one, that other variable changes its type accordingly.
Consider python:
x = 3 # x is an integer
y = "Hello world" # y is a string
x = y # now x is a string, too
In C++, a variable can never change its type. You can however use
polymorphism to get a more dynamic behaviour, within some limits.
You can implement a VB6- style variant class, which I'm doing now. Of course
on the inside you must use static type checking, but so does VB's variant.
variant x = 3; // it's an int
variant y = "hello"; // this one's a string
x = y; // now it's a string too
Mine so far supports that, and operator+, but I've got the basic framework
done and it will be easy to do the rest of the operators. I'll post it here
when I'm done.
- Pete