cplusplus.com cplusplus.com
cplusplus.com   C++ : Forums : Beginners : void**
  Search:
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forums
Forums
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Articles
Lounge
Jobs

-

question  void**

cva (25)
what is the meaning of void**....
|
Grey Wolf (585)
That is a pointer to a void pointer. A void pointer can't be dereferenced, but a void** can. I.e.

void *x[100];
void **xp = x;

With the above declaration of xp you should be able to do e.g. xp[17] to get at the 18th element of the array x.

PS. Please post your questions once.
| Last edited on
ropez (311)
It's a pointer to a pointer to void (unspecified type). It means that this variable (memory location) contains an address to a memory location, that contains an address to another memory location, and what is stored there is not specified.

To be used for something useful, the pointer that it points to has to be casted to something.

1
2
3
4
5
6
7
8
9
10
11
int i = 10;

void * vp = &i;
void ** vpp = &vp;

// ...

void * other = *vpp; // Get address that vpp is pointing to
int * ip = static_cast<int*>(other); // Cast to pointer to integer
int j = *ip; // Read an int from the same memory location
// j == i == 10; 
|
cva (25)
Thanks for ur guidence wolf and ropez......sorry wolf, technical error...:)
|

This topic is archived - New replies not allowed.
Home page | Privacy policy
© cplusplus.com, 2000-2008 - All rights reserved - v2.2
Spotted an error? contact us