title: Accessing function pointer inside class
body: <p>I am defining function pointer inside a class and trying to access it through an instance of the class but it shows an error.</p>
  
  <p>Here is the code:</p>
  
  <pre><code> 1 #include&lt;stdio.h&gt;
   2 
   3 class pointer {
   4 public:
   5    int (pointer::*funcPtr)(int);
   6    pointer() {
   7       funcPtr = &amp;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-&gt;*funcPtr)(3);
  22 }
  </code></pre>
  
  <p>It shows a compile time error:</p>
  
  <pre><code>checkPointer.cpp:21:15: error: ‘funcPtr’ was not declared in this scope
  </code></pre>
  
  <p>please help me.</p>
  
  <p>Thank You in advance.</p>