Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#include <iostream.h>
class c1{
public:
c1::c1(){}
void sample1();
void sample2();
void sample3();
void sample4();
void sample5();
void sample6();
};
void c1::sample1(){cout<<"sample1\n";}
void c1::sample2(){cout<<"sample2\n";}
void c1::sample3(){cout<<"sample3\n";}
void c1::sample4(){cout<<"sample4\n";}
void c1::sample5(){cout<<"sample5\n";}
void c1::sample6(){cout<<"sample6\n";}
class c2{
public:
c2::c2( void(c1::*ptr)() ):method_ptr(ptr){};
void setmethod(void(c1::*ptr)());
void fire();
private:
void (c1::*method_ptr)();
};
class c3{
public:
c3::c3():method_ptr(fxna){};
void setmethod(int x);
void fxna(){cout<<"fxna\n";}
void fxnb(){cout<<"fxnb\n";}
void fxnc(){cout<<"fxnc\n";}
private:
void (c3::*method_ptr)();
};
void c2::fire(){c1 temp;(temp.*method_ptr)();}
void c2::setmethod(void(c1::*ptr)()){method_ptr=ptr;}
void c3::setmethod(int x){
switch(x)
{
case 1:method_ptr = fxna;break;
case 2:method_ptr = fxnb;break;
case 3:
default:method_ptr = fxnc;break;
}
}
int main()
{
c2 mc2(&c1::sample1);
mc2.fire();
mc2.setmethod(&c1::sample2);
mc2.fire();
mc2.setmethod(&c1::sample3);
mc2.fire();
mc2.setmethod(&c1::sample4);
mc2.fire();
mc2.setmethod(&c1::sample5);
mc2.fire();
mc2.setmethod(&c1::sample6);
mc2.fire();
c3 mc3;
cout<<"\n\n\n\nbeginning\n\n\n\n";
mc3.setmethod(1);
mc3.setmethod(2);
mc3.setmethod(3);
return 0;
}