Hello, I am trying to create template of something like list element. I wanted to overload operator + so it returns pointer to element this + n position "forward" on my list.
error C2440: '=' : cannot convert from 'LE<T> *const ' to 'LEP *'
with
[
T=LEP
]
Why??
It seems to me that I can't use pointer this in class templates.
Is it true?
I need it in other templates too so, if it's true then I'm in trouble, if not please tell me how can I do that.
Thanks for reply.
You are right. It'll be completely mess when I'll use e.g. int but I never do that.
I solve my problem by changing line 11 like this:
result = reinterpret_cast<T*> (this);
Error was caused by my poor understanding of polymorphism.
What? No!
Change the type of 'result' to 'LE<int> *'. Don't use casting!
I can't correct you on the declaration of 'LEP'. Inheritance isn't one of my favorite features of C++, so I don't use it much. Even less when combined with templates. I can tell you, though, that that's not right.