Archived

This topic is now archived and is closed to further replies.

a generic pointer to pointers (c++ issue)

This topic is 5114 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, Can you exlain me how to assign pointers to generic pointers (void*) cast, and to generic pointer to pointers (void**) cast... i think i know... correction, i thought i knew Regards, kalash

Share this post


Link to post
Share on other sites
You want to obtain a normal pointer from a void pointer?

int *Ptr = (int*) void_ptr;

You want the value of a void pointer?

int Value = *(int*) void_ptr;

You want to assign a normal pointer from a pointer pointer?

void *new_ptr = *void_ptr;

Not void?

int *new_ptr = (int*) *void_ptr;

Sorry if I misread the problem.

Jiia

Share this post


Link to post
Share on other sites
Yup yup yup.... ahhh all those notations.. YOURE WORTH REAL MONEY, thanks so much for your help ))) I really needed that as i haven''t seen c++ for years and couldnt be bothered to go read the books again.

btw sorry if my english is not good...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
if your going to cast pointers to void.. you should use C++ casting

void* pvoid = reinterpret_cast<void*>(pint);
void** ppvoid = reinterpret_cast<void**>(ppint);

(void*) is old c-style casting

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
if your going to cast pointers to void.. you should use C++ casting

void* pvoid = reinterpret_cast<void*>(pint);
void** ppvoid = reinterpret_cast<void**>(ppint);

(void*) is old c-style casting



When dealing with void pointers, its a good idea to explicitly cast.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by PlayGGY
quote:
Original post by Anonymous Poster
if your going to cast pointers to void.. you should use C++ casting

void* pvoid = reinterpret_cast&lt;void*&gt;(pint);
void** ppvoid = reinterpret_cast&lt;void**&gt;(ppint);

(void*) is old c-style casting



When dealing with void pointers, its a good idea to explicitly cast.


That is explicit casting, C++ style.

Share this post


Link to post
Share on other sites