I\'ve created a class that can be parameterised by anything that can be converted to Numeric
class Complex[T <% Numeric[T]] (val real : T, val imag : T) {
You are using it wrong. The correct usage is like this:
class Complex[T](val real : T, val imag : T)(implicit num: Numeric[T]) {
import num._ // make implicit conversions available
//... complex number methods ...
}
It is the same difference as in between Ordered
and Ordering
. An Ordered[T]
instance can be compared to T
, while an Ordering[T]
provides a method that compares a a couple of T
.