returning a pointer to a member function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Fraser Ross

    #1

    returning a pointer to a member function

    Can someone remind me of the syntax for a function that returns a
    pointer to a member function? The functions are going to be defined at
    the declaration. They will take no parameters. I've given the pointer
    members here.

    TColor const (TuserInterface ::*
    pointerToGetPoi ntColourFunctio n_)(unsigned int const) const;

    TColor const (TuserInterface ::*
    Get_GetPointCol ourFunctionPoin ter())((unsigne d int) const) const {
    return pointerToGetPoi ntColourFunctio n_;
    };




    void (TuserInterface ::* pointerToSetPoi ntColourFunctio n_)(unsigned int
    const, TColor const) const;

    void (TuserInterface ::* Get_SetPointCol ourFunctionPoin ter())((unsigne d
    int, TColor) const) {
    return pointerToSetPoi ntColourFunctio n_;
    };


    *** Free account sponsored by SecureIX.com ***
    *** Encrypt your Internet usage with a free VPN account from http://www.SecureIX.com ***
  • Fraser Ross

    #2
    Re: returning a pointer to a member function

    > TColor const (TuserInterface ::*[color=blue]
    > pointerToGetPoi ntColourFunctio n_)(unsigned int const) const;
    >
    > TColor const (TuserInterface ::*
    > Get_GetPointCol ourFunctionPoin ter())((unsigne d int) const) const {
    > return pointerToGetPoi ntColourFunctio n_;
    > };[/color]
    TColor const (TuserInterface ::* Get_GetPointCol ourFunctionPoin ter()
    const)(unsigned int) const {
    return pointerToGetPoi ntColourFunctio n_;
    };
    The pointed to function is constant. I appear to have had a syntax
    mistake with the constness.

    [color=blue]
    > void (TuserInterface ::* pointerToSetPoi ntColourFunctio n_)(unsigned int
    > const, TColor const) const;
    >
    > void (TuserInterface ::* Get_SetPointCol ourFunctionPoin ter())((unsigne d
    > int, TColor) const) {
    > return pointerToSetPoi ntColourFunctio n_;
    > };[/color]
    void (TuserInterface ::* Get_SetPointCol ourFunctionPoin ter())(unsigned
    int, TColor) {
    return pointerToSetPoi ntColourFunctio n_;
    };
    A similar syntax mistake here I think.


    *** Free account sponsored by SecureIX.com ***
    *** Encrypt your Internet usage with a free VPN account from http://www.SecureIX.com ***

    Comment

    • Pete Becker

      #3
      Re: returning a pointer to a member function

      Fraser Ross wrote:
      [color=blue]
      > Can someone remind me of the syntax for a function that returns a
      > pointer to a member function?[/color]

      typedef void (MyClass::*pmf) (int);
      pmf func()
      {
      return &MyClass::mem_f unc;
      }

      If for some reason you don't want to use a typedef, you're on your own.

      --

      Pete Becker
      Roundhouse Consulting, Ltd.

      Comment

      Working...