943,917 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 918
  • C++ RSS
Sep 7th, 2007
0

void** syntax question

Expand Post »
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
C++ Syntax (Toggle Plain Text)
  1. bool pop(Node **stack, void **data)
Similar Threads
Reputation Points: 10
Solved Threads: 1
Newbie Poster
jsap is offline Offline
4 posts
since Aug 2007
Sep 7th, 2007
0

Re: void** syntax question

I think you have to do something like this because int** isn't a compatible type with void**.
C++ Syntax (Toggle Plain Text)
  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. }
Reputation Points: 180
Solved Threads: 34
Posting Whiz
Hamrick is offline Offline
322 posts
since Jun 2007
Sep 7th, 2007
0

Re: void** syntax question

that worked, thanks
Reputation Points: 10
Solved Threads: 1
Newbie Poster
jsap is offline Offline
4 posts
since Aug 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: sum of specific integers
Next Thread in C++ Forum Timeline: error LNK2001: unresolved external symbol





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC