Thread: Problem with a function pointer syntax

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by whiteflags View Post
    test is a function prototype, so you get that error, see this.
    Yeah, still wet behind the ears with C++. But the actual error persisted, it was because of the difference between:

    Code:
    a.*func(1,2);  // nope
    (a.*func)(1,2); // okay
    Now I think that's the answer, since you can call any suitable member of an instance of X through the pointer fptr.
    How about getting that to work as a param to a method (2nd example post #7) which is what the OP wants? I'm starting to think it cannot be done (a method cannot accept a function pointer to another method of the same class).
    Last edited by MK27; 07-02-2011 at 07:14 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 12-01-2010, 01:05 PM
  2. Function syntax to return a pointer...
    By tzuch in forum C Programming
    Replies: 1
    Last Post: 05-29-2008, 07:53 AM
  3. HELP!! Function Definition problem? Syntax Error I think..
    By felixgun in forum C++ Programming
    Replies: 12
    Last Post: 11-04-2006, 04:49 AM
  4. struct pointer to function syntax
    By kermit in forum C Programming
    Replies: 2
    Last Post: 03-21-2004, 04:01 PM
  5. syntax to pass a member function pointer to another class?
    By reanimated in forum C++ Programming
    Replies: 4
    Last Post: 11-27-2003, 05:24 PM