Creating a Pointer to Member Function

 








  PRODUCT  :  C++                                    NUMBER  :  639

  VERSION  :  All

       OS  :  PC DOS

     DATE  :  August 12, 1992                          PAGE  :  1/1


    TITLE  :  Creating a Pointer to Member Function





  #include <stdio.h>


  class Matterhorn {

  public:

      void bobsled( int x ) { printf( "-> %d <-", x ); }

  };


  void main( void )

  {

      Matterhorn m;


      // pmf is a pointer to a member function

      // that accepts an int and returns nothing

      void ( Matterhorn::*pmf )( int );


      // assign pmf the address of bobsled

      pmf = &(Matterhorn::bobsled);


      // here's how we call function bobsled()

      (m.*pmf)(3);

  }

  DISCLAIMER: You have the right to use this technical information

  subject to the terms of the No-Nonsense License Statement that

  you received with the Borland product to which this information

  pertains.

























Comments

Popular posts from this blog

BOTTOM LIVE script

Evidence supporting quantum information processing in animals

ARMIES OF CHAOS