Re: Declaring super types
Date: Mon, 19 Apr 2010 06:16:39 -0700 (PDT)
Message-ID: <a3363227-dd02-421b-9072-a35f3a2b02d9_at_q23g2000yqd.googlegroups.com>
On Apr 19, 8:23 pm, Nilone <rea..._at_gmail.com> wrote:
> How would you want to use that relationship? Any examples to study?
For example, functions that accept RATIONAL values could be passed
values of type INTEGER.
It’s quite useful. E.g. even in a low level language like C there are
handy conversions amongst the built-in types:
double sqrt(double);
double x = sqrt(4); // integer 4 has implicit conversion to double
BTW C++ allows one to write user-defined value types supporting
implicit conversion from builtin-types, by writing single argument
constructors. Actually I just posted to comp.lang.c++.moderated
asking whether it can be regarded as a general purpose approach to
value subtyping in that language. But it does seem strange for a type
