A typedef
does nothing more than establish another name for an existing type.
Therefore your question boils down to whether you can disable implicit conversions between unsigned short
and double
, which is not possible in general.
Two ways exist to deal with this problem:
First, you can make Altitude
and Time
into their own types (read: define class
es instead of typedef
s) and ensure that they can be easily converted to and from their underlying numeric types - but not each other.
Second, you can ensure that whatever you do is protected by language constructs, e.g. if you have a function f
that should take an Altitude
a.k.a. unsigned short
, you can overload it with another function f
that takes an Time
a.k.a. double
and causes an error. This provides a better overload match and would thus prevent the implicit conversion in that case.