void** syntax question

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Aug 2007
Posts: 4
Reputation: jsap is an unknown quantity at this point 
Solved Threads: 1
jsap jsap is offline Offline
Newbie Poster

void** syntax question

 
0
  #1
Sep 7th, 2007
I have a function that takes a void** and I want to pass an integer in to the function but can not seem to figure out the syntax

here is the function prototype
  1. bool pop(Node **stack, void **data)
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 322
Reputation: Hamrick will become famous soon enough Hamrick will become famous soon enough 
Solved Threads: 33
Hamrick's Avatar
Hamrick Hamrick is offline Offline
Posting Whiz

Re: void** syntax question

 
0
  #2
Sep 7th, 2007
I think you have to do something like this because int** isn't a compatible type with void**.
  1. int i = 123;
  2. int *p = &i;
  3.  
  4. void pop( void **data ) {
  5. *data = p;
  6. }
  7.  
  8. int main() {
  9. int *q;
  10. void *pv;
  11.  
  12. pop( &pv );
  13. q = static_cast<int*>( pv );
  14.  
  15. return 0;
  16. }
The truth does not change according to our ability to stomach it.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 4
Reputation: jsap is an unknown quantity at this point 
Solved Threads: 1
jsap jsap is offline Offline
Newbie Poster

Re: void** syntax question

 
0
  #3
Sep 7th, 2007
that worked, thanks
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC