2 ms·
There can be an awful lot of dynamic typing hiding inside C++ code bases, by the way. C++ has very good support for dynamic typing. You can make C++ look almos
by kazinator 11y ago
There can be an awful lot of dynamic typing hiding inside C++ code bases, by the way.
C++ has very good support for dynamic typing. You can make C++ look almost like Javascript, if you want.
- paulddraper 11y agoC++ has polymorphism and templates. If you have a lot of dynamic typing, you may want to look at C instead.
- marvy 11y agoHow on earth do you make C++ like JS? I'm no JavaScript programmer so correct me if I'm wrong, but I think this is legal: x = 5; x = "five"; How do you do that in C++? In C# they have the dynamic keyword, but C++? I guess boost has all sorts of magic, but... good support?
- kazinator 11y agoThat can be easily made to work in C++95. x can be of a smart pointer type (let's call it "var") which acts as reference to an anyobject class instance, which comes in varieties like string_anyobject, integer_anyobject and so on. The smart pointer class can have a few assignment operators and conversion constructors for usage like var x = "lit"; or x = 5.