Timeline for Why do you have to specify the data type when declaring variables?
Current License: CC BY-SA 3.0
4 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 29, 2019 at 18:38 | comment | added | dmckee --- ex-moderator kitten | @QuentinUK But if you write for (auto i=0; i<SomeStdVector.size(); ++i) your linter is going to complain because it deduced a signed type and you proceed to compare it to an unsigned type. You have to write auto i=0ul (putting the type information in explicitly again, so should just write size_t i=0 in the first place). | |
| Mar 21, 2016 at 21:20 | comment | added | MathematicalOrchid | @QuentinUK In C#, you can put var x=1 with similar results. But that's nothing; in Haskell, you can write your entire program with no type signatures at all, yet it's all statically typed, and you still get errors if you make a mistake... (Not exactly mainstream though.) | |
| Mar 21, 2016 at 18:51 | comment | added | QuentinUK | In C++ you can put "auto x=1" and it knows it's an int. auto y=1.2; auto z = 'Z'; etc | |
| Mar 21, 2016 at 14:36 | history | answered | MathematicalOrchid | CC BY-SA 3.0 |