M
My interest
Question is how to make the following class compile?
class foo<T>
{
private T a, b;
public T Sum()
{
return a + b; // this line does not compile.
}
}
The background is that I want this class to be instantiated by all the
"numeric friendly" classes (i.e. those support operator like +,
- ...). These should include both built-in types, (e.g. double) and
user defined class.
Thanks.
class foo<T>
{
private T a, b;
public T Sum()
{
return a + b; // this line does not compile.
}
}
The background is that I want this class to be instantiated by all the
"numeric friendly" classes (i.e. those support operator like +,
- ...). These should include both built-in types, (e.g. double) and
user defined class.
Thanks.