Skip to content

Instantly share code, notes, and snippets.

@st4rk
Created October 19, 2016 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save st4rk/2d720bb866cc39c68f06f0d6a387919d to your computer and use it in GitHub Desktop.
Save st4rk/2d720bb866cc39c68f06f0d6a387919d to your computer and use it in GitHub Desktop.
#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