Anonymous user
Implicit type conversion: Difference between revisions
m
added whitespace before the TOC, added a Task (bold) header.
m (added whitespace before the TOC (table of contents).) |
m (added whitespace before the TOC, added a Task (bold) header.) |
||
Line 6:
The alternative would be to ''explicitly'' convert a value from one type to another, using a ''function'' or some other mechanism (e.g. an explicit cast).
The following code samples demonstrate the various type conversions in each language, and give an example of a ''implicit type conversion'' path from the smallest possible variable size to the largest possible variable size. (Where the size of the underlying variable's data strictly increases).▼
;Task:
▲
In strong typed languages ''some'' types are actually mutually incompatible. In this case the language may have disjoint type conversion paths, or even branching type conversion paths. (Where it occurs in a specific language, it is demonstrated in the code samples below.)
Line 12 ⟶ 14:
Languages that don't support ''any'' ''implicit type conversion'' are detailed in the [[:Category:Maintenance/OmitCategoriesCreated|/Omit]] categories at the bottom of this page.
Indicate if the language supports ''user defined'' type conversion definitions.
And give an example of such a definition. (E.g. define an ''implicit type conversion'' from '''real''' to '''complex''' numbers, or from '''char''' to an array of '''char''' of length 1.)
<br><br>
|