pointer to member function/variable info? 
Author Message
 pointer to member function/variable info?

can anyone suggest a good online overview of pointers to member function and
member variables?

I looking for specifically information on properly initializing pointers for
this type of access..

thank you in advance...
Jamie



Sat, 07 Sep 2002 03:00:00 GMT  
 pointer to member function/variable info?


Quote:

> can anyone suggest a good online overview of pointers to member function
and
> member variables?

This is covered in the FAQ.

http://marshall-cline.home.att.net/cpp-faq-lite/

--
Dan Evens
Standard disclaimers etc. No spam please.
Just because nobody complains does not
mean that all parachutes are perfect.



Sat, 07 Sep 2002 03:00:00 GMT  
 pointer to member function/variable info?

Quote:
> can anyone suggest a good online overview of pointers to member function
and
> member variables?

> I looking for specifically information on properly initializing pointers
for
> this type of access..

This information can easily be looked up at www.deja.com (look for string
"::*"). Two examples

// BC EX1
#pragma warning(disable:4786)
#include <iostream>
#pragma warning(disable:4786)
#include <functional>
using std::ostream;
using std::mem_fun_ref;
using std::mem_fun1_ref;
using std::bind2nd;
using std::cout;
using std::bind1st;
using std::endl;

int main()
{
  ostream& (ostream::*g)(int) = &ostream::operator<<;

  // print 2
  (cout.*g)(2);

  // print 4
  mem_fun_ref(g)(cout,4);

  // print 6:
  bind2nd(mem_fun1_ref(g),6)(cout);

  // print 8:
  bind1st(mem_fun1_ref(g),cout)(8);

  cout << endl;

 return 0;

Quote:
}

// EC EX1

// BC EX2
struct cl
{
 int (cl::*q)(void);

 int f(void){ return 0; }
 int g(void){ return 1; }

 void dosome()
 {
  q = cl::f;
  (this->*q)();
  q = cl::q;
  (this->*q)();
 }

Quote:
};

int main(void)
{
 cl c;
 c.dosome();
 return 0;
Quote:
}

// EC EX2

TiTi



Sun, 08 Sep 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. static function access member variable and member function

2. Function Pointer as a member variable

3. member function and member variable

4. member function and member variable

5. member function and member variable

6. Pointers to member functions as function arguments

7. (member) function returning pointer to functions like itself?

8. Getting pointer to non-static member function from C callback function

9. Function Pointer for Member Function

10. Function pointer for Member Function

11. function pointer to a member function

12. Function pointer / function member

 

 
Powered by phpBB® Forum Software