View Single Post
  #6 (permalink)  
Old 29-Jun-2009, 23:00
ken_yap ken_yap is online now
Flux Capacitor Penguin
 
Join Date: Jun 2008
Location: GMT+10
Posts: 5,222
ken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud of
Default Re: Shared memory and C++

It means that most of the time, casting is not needed in C++. The typing rules should handle most of the type coercions automatically, or the coercions should coded in a few places. If you find yourself needing a cast, perhaps something is wrong with the code.

Also if an arbitrary area of memory is declared as void *, this is automatically compatible with any typed pointer, and you don't need a cast. (Provided alignment constraints are adhered to.) malloc() returns a void * that is compatible with all typed pointers. Of course, you really should be using new() instead of malloc().
Reply With Quote