2 Replies - 7519 Views - Last Post: 21 August 2010 - 01:44 PM Rate Topic: -----

#1 harris2107  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 17-August 10

what is difference between static and dynamic cast in c++

Posted 21 August 2010 - 01:23 PM

what is difference between static and dynamic cast in c++?
Is This A Good Question/Topic? 0
  • +

Replies To: what is difference between static and dynamic cast in c++

#2 Oler1s  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1395
  • View blog
  • Posts: 3,884
  • Joined: 04-June 09

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.
Was This Post Helpful? 0
  • +
  • -

#3 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4359
  • View blog
  • Posts: 12,176
  • Joined: 18-April 07

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. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1