
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
After all, the inheritance chain could be anything you want: even Interface<CBase>, even Interface<C<B<A<CBase>>>>, there are tons of variants. We would have to cast CBase sequentially to all possible variants, which is unrealistic.
I remember I was going to implement storing information about interfaces in class object itself, and in addition to existing interface pads to make independent interface classes that would work as a wrapper over our pad. But then I came to the conclusion that all this is unnecessary and redundant. In practice, I've never seen a need to cast a base class to any interface, it just doesn't make any sense. The only option is to find out if the class supports this interface for debugging purposes, but we don't need casting for that.
In my opinion, we should store the interface in the interface. Interface<T,CBase>::GetComparer().Compare(CBase &a, T& b); I sketched some code there for an example, but I don't really want to clutter up the forum with too many letters.
In my opinion, the interface should be stored in the interface itself. Interface<T,CBase>::GetComparer().Compare(CBase &a, T& b); I sketched some code there for an example, but I don't really want to clutter up the forum with too many letters.
Go ahead and post it. Anyway, it's not rubbish but a subject of discussion. But in that thread from which the discussion was moved here, it would be inappropriate.
ok)
ok)
Why isIComparer::Compare(CBase &op1, T &op2) method there if both arguments should be T
And why thereIComparer::Compare(CBase &op1, T &op2) method if both arguments must be T
Is it only possible to compare the same types? My assumption is that it's not. Make T==CBase and there will be both arguments T )
Ah, got it, you've got it wrong then. IComparer class in your case should be like IComparer<T1,T2,CBase>. Accordingly the method will be:
And when you inherit the class you will overload exactly this method, everything will fall into place.Ah, I see, you've got it all wrong then. IComparer class in your case should be like IComparer<T1,T2,CBase>:
And when you inherit a class, you will overload this method, everything will fall into place.And what's the meaning of this CBase? And why exactly 2 values of one type must be compared?
dynamic cast for comparison? are you out of your mind?
a pure virtual function is written like this -virtual int CompareTo(Number *par) = 0 ;
it is the compiler that will be cursed and not the self-written exception surrogate.
a pure virtual function is written like this -virtual int CompareTo(Number *par) = 0;
the compiler will be cursed instead of the self-written exception surrogate.
I don't need the compiler to swear because I constantly manipulate base type classes (Number in this example). If the compiler swears at it, the code won't run at all