View Single Post
  #8 (permalink)  
Old 29-Jun-2009, 23:16
castord's Avatar
castord castord is offline
Student Penguin
 
Join Date: Jun 2008
Location: As. - Paraguay - GMT -4
Posts: 95
castord hasn't been rated much yet
Default Re: Shared memory and C++

Yes, you're right. I did the cast because I get a compilation error without it.
The following results in: invalid conversion from ‘void*’ to ‘test*’

Code:
test *to	= destination;
I used malloc() because I though there were something wrong with my C++ code.

Originally Clone() was not function, it was a method that uses new operator to dynamically allocate memory.

I also tried overloading new() and returning the start of the shared memory. It wasn't work either. It will be crazy to write a function that updates the pointer in every method that manipulates the object so I voted to a simply structure that imitates straightforward memory allocation but as you saw it wasn't that simple (at least for me).
Reply With Quote