b5_4_5.cxx

We use cookies. Read the Privacy and Cookie Policy

b5_4_5.cxx

#include ‹stream.hxx›

struct cl

{

 char* val;

 void print(int x) { cout ‹‹ val ‹‹ x ‹‹ " "; }

 cl(char *v) { val = v; }

};

typedef void (cl::*PROC)(int);

main()

{

 cl z1("z1 ");

 cl z2("z2 ");

 PROC pf1 = &cl::print;

 PROC pf2 = &cl::print;

 z1.print(1);

 (z1.*pf1)(2);

 z2.print(3);

 ((&z2)-›*pf2)(4);

}