This shows you the differences between two versions of the page.
c_ptrfunc [2013/04/07 00:41] konovalov created |
c_ptrfunc [2013/04/07 00:42] (current) konovalov [указатель на статичный метод] |
||
---|---|---|---|
Line 17: | Line 17: | ||
from func(): 19 | from func(): 19 | ||
==== указатель на статичный метод ==== | ==== указатель на статичный метод ==== | ||
- | class MyClass{ | + | class MyClass{ |
- | public: | + | public: |
- | static void method(int xIn){ | + | static void method(int xIn){ |
- | cout << "from MyClass::method() " << xIn << endl; | + | cout << "from MyClass::method() " << xIn << endl; |
- | } | + | } |
- | }; | + | }; |
- | + | ||
- | int main(int argc, char *argv[]){ | + | int main(int argc, char *argv[]){ |
- | MyClass::method(23); | + | MyClass::method(23); |
- | void (*ptrMethod)(int); | + | void (*ptrMethod)(int); |
- | ptrMethod = &MyClass::method; | + | ptrMethod = &MyClass::method; |
- | ptrMethod(44); | + | ptrMethod(44); |
- | } | + | } |
+ | вывод: | ||
+ | from MyClass::method() 44 | ||
==== указатель на метод ==== | ==== указатель на метод ==== | ||
class MyClass{ | class MyClass{ |