Is there a way to carryout explicit data type convertions automatically? if the complier can see your errors why can't it correct them?

Recommended Answers

All 3 Replies

Because if it does that it would be guessing (do you want a guessing compiler?)

It can't always be sure what you mean, so it doesn't know what to correct them based on.

What if it converted floats over to ints automatically? What would it do with the fractions?

scru makes an excellent point. When you're working with a type-safe language, one of the key points is that the compiler is going to be VERY picky about making sure types match up.

Personally, I wouldn't even use the explicit conversion unless I absolutely had a good reason...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.