what is difference between static and dynamic cast in c++?
2 Replies - 3750 Views - Last Post: 21 August 2010 - 01:44 PM
#1
what is difference between static and dynamic cast in c++
Posted 21 August 2010 - 01:23 PM
Replies To: what is difference between static and dynamic cast in c++
#2
Re: what is difference between static and dynamic cast in c++
Posted 21 August 2010 - 01:36 PM
I suggest you read the forum rules, including the part about we don't do your homework. Then, grab a C++ book and start reading.
#3
Re: what is difference between static and dynamic cast in c++
Posted 21 August 2010 - 01:44 PM
dynamic_cast is for pointers and references to objects. It is a cast which is designed to give you a full complete object and is always successful when used with converting a derived class to its base class but not vice versa. Static_cast on the other hand allows you to cast between base and derived classes either way, but this means it could also fail. With static_cast it is up to the programmer to make sure the cast is legit... aka there is no safety check to make sure things never fail.
Hope that makes sense.
Hope that makes sense.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|