Go Back  DVD Talk Forum > General Discussions > Other Talk
Reload this Page >

C++ Pointer to Member function question

Other Talk "Otterville" plus Religion/Politics

C++ Pointer to Member function question

Old 02-06-08, 12:44 PM
  #1  
DVD Talk Hero
Thread Starter
 
Join Date: Nov 1999
Posts: 36,981
Likes: 0
Received 0 Likes on 0 Posts
C++ Pointer to Member function question

I want to pass a pointer to a member function to another function. What is the correct syntax?

I have myObject and it has a member function myFunction. How do i actually pass it to foo?


void foo(myObjectType* ptr, void(myObjectType::*func)())
Old 02-06-08, 12:47 PM
  #2  
Senior Member
 
Join Date: Apr 1999
Location: SW Burbs of Chicago
Posts: 735
Likes: 0
Received 0 Likes on 0 Posts
Originally Posted by Venusian
I want to pass a pointer to a member function to another function. What is the correct syntax?

I have myObject and it has a member function myFunction. How do i actually pass it to foo?


void foo(myObjectType* ptr, void(myObjectType::*func)())

First you post in Tech Talk.... :P
Old 02-06-08, 12:49 PM
  #3  
DVD Talk Hero
Thread Starter
 
Join Date: Nov 1999
Posts: 36,981
Likes: 0
Received 0 Likes on 0 Posts
I thought about it, but it's not a question about Technology
Old 02-06-08, 01:10 PM
  #4  
DVD Talk Special Edition
 
Join Date: Apr 2003
Posts: 1,608
Likes: 0
Received 0 Likes on 0 Posts
It looks like you are already passing a pointer to the object itself, why not call the function from the pointer to the object?
Old 02-06-08, 01:14 PM
  #5  
DVD Talk Hero
Thread Starter
 
Join Date: Nov 1999
Posts: 36,981
Likes: 0
Received 0 Likes on 0 Posts
I figured it out...thanks

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Thread Tools
Search this Thread

Archive - Advertising - Cookie Policy - Privacy Statement - Terms of Service - Do Not Sell My Personal Information

Copyright 2018 MH Sub I, LLC dba Internet Brands. All rights reserved. Use of this site indicates your consent to the Terms of Use.