Skip to content

Instantly share code, notes, and snippets.

@st4rk
Created Oct 19, 2016
Embed
What would you like to do?
#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