
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
Did you find a security hole? )
Wouldn't it be better to use polymorphism?
Approximately:
The thing is that the inheritor classes CChartObjectRectLabel, CChartObjectButton and CChartObjectEdit, have their own unique methods that need to be accessed. And the base class CChartObject from the standard library does not have the same virtual ones.
On my example above...
access to methods of inheritor classes?
...it turns out like this:
Yeah. It is unorthodox to cast directly like that. In pluses there is dynamic_cast specifically for this purpose, here you cannot cast it completely correctly and it is a potential source of implicit and serious errors. And by seriousness it is not much better than unsafe pointers and references.
Yes, before asking a question here on the forum, I found on the net that C++ has the dynamic_cast operator (a mechanism of dynamic data identification).
Now I'm looking at the link above:
So it is a mandatory condition? And if there are no virtual methods in the base class, then dynamic_cast will not work?
P.S. >>> Here I am reading more about dynamic_cast (MSDN).
Shit, and you talk about language safety after that?
You probably think that you can freely cast to anything like in C/C++.
It is not so and there is nothing wrong with security.
You probably think that you can freely cast to anything as in C/C++.
It is not so and there is nothing wrong with safety.
I got this error by accident, which seems to confirm your words. )
It is not and there is nothing wrong with safety.
No, you can't properly check dynamic_cast at compile time.
The comment above shows the result of the casting check in rantime.
It is very rigid, it works on RTTI mechanism, because we know exactly who is who in case of ghosts.
The comment above shows the result of the casting check in rantime.