[ create a new paste ] login | about

Link: http://codepad.org/eUtSGfbV    [ raw code | output | fork ]

johannes - C++, pasted on Nov 2:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class SomeClass
{
public:
    void func1(int x) const { std::cout << "calling func 1 with arg. " << x << std::endl; }
    void func2(int x) const { std::cout << "calling func 2 with arg. " << x << std::endl; }
    void func3(int x) const { std::cout << "calling func 3 with arg. " << x << std::endl; }
};

void callSomeFunction(void (SomeClass::*m)(int) const)
{
    SomeClass obj;
    (obj.*m)(1);
}

int main()
{
    void (SomeClass::*x)(int) const;
    x = &SomeClass::func2;
    callSomeFunction(x);         // calling func 2 with arg. 1
    return 0;
}


Output:
1
calling func 2 with arg. 1


Create a new paste based on this one


Comments: