H
Herby
Given class B C and D all inherit from class A
They all override a method of the form:
Add( A^ lhs, A^ rhs );
But only specific conversions are allowed
So if i was defining Add for class D :
D::Add( A^ lhs, A^ rhs )
{
Value = ((D)lhs)->Value + ((D)rhs)->Value;
}
Ony C can be converted to type D and D itself.
Most of the time the arguments will be of type D itself.
How can i specify C can be cast to D ?
So C will intermediately convert itself to D.
But the others cannot.
How much overhead in terms of performance is this costing when
converting a C to a D
and when converting a D to itself?
Should i use safe_cast ?
They all override a method of the form:
Add( A^ lhs, A^ rhs );
But only specific conversions are allowed
So if i was defining Add for class D :
D::Add( A^ lhs, A^ rhs )
{
Value = ((D)lhs)->Value + ((D)rhs)->Value;
}
Ony C can be converted to type D and D itself.
Most of the time the arguments will be of type D itself.
How can i specify C can be cast to D ?
So C will intermediately convert itself to D.
But the others cannot.
How much overhead in terms of performance is this costing when
converting a C to a D
and when converting a D to itself?
Should i use safe_cast ?