a generic pointer to pointers (c++ issue)
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
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
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
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...
btw sorry if my english is not good...
Err... C++... generic programming...
[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || E-Mail Me ]
void*
? No, no, no; templates. [ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || CUJ || MSVC++ Library Fixes || BarrysWorld || E-Mail Me ]
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
void* pvoid = reinterpret_cast<void*>(pint);
void** ppvoid = reinterpret_cast<void**>(ppint);
(void*) is old c-style casting
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.
quote:Original post by PlayGGYquote: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.
That is explicit casting, C++ style.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement