This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <functional> | |
class test { | |
public: | |
test(); | |
~test(); | |
void whatever_1(); | |
void whatever_2(); | |
void run(); | |
private: | |
void (test::*funptr[2])(); | |
unsigned int ddd; | |
}; | |
test::test() { | |
funptr[0] = &test::whatever_1; | |
funptr[1] = &test::whatever_2; | |
ddd = 25; | |
} | |
test::~test() { | |
} | |
void test::whatever_1() { | |
std::cout << "oops" << std::endl; | |
} | |
void test::whatever_2() { | |
std::cout << "oopps 2 " << ddd << std::endl; | |
} | |
void test::run() { | |
(this->*funptr[0])(); | |
(this->*funptr[1])(); | |
ddd = 12302103; | |
(this->*funptr[0])(); | |
(this->*funptr[1])(); | |
} | |
int main(int argc, char **argv) { | |
test a; | |
a.run(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment