I am defining function pointer inside a class and trying to access it through an instance of the class but it shows an error.
Here is the code:
1 #include<stdio.h>
2
3 class pointer {
4 public:
5 int (pointer::*funcPtr)(int);
6 pointer() {
7 funcPtr = &pointer::check;
8 }
9
10
11 int check(int a)
12 {
13 return 0;
14 }
15
16 };
17
18 int main()
19 {
20 pointer *pt=new pointer;
21 return (pt->*funcPtr)(3);
22 }
It shows a compile time error:
checkPointer.cpp:21:15: error: ‘funcPtr’ was not declared in this scope
please help me.
Thank You in advance.