As far as I know each created object has its own address, and each object's method also has its own address. I want to verify that with the following idea:
Step 1: Build class A with public method, its name is "method".
Step 2: Create two objects in class A, they are object "b" and object "c".
Step 3: Access the addresses of "b.method" and "c.method" to check that they are equal by using a function pointer.
But I met the problem in step 3 and have found every way to solve but failed. So I posted up here to ask people to help me how to verify what I said above. Thanks everyone! And here is my C++ code:
#include<iostream>
using namespace std;
class A
{
  public:
     int a;
     void method()
     {
       //do something
     }
     static void (*fptr)();
};
int main()
{
    A b, c;
    A::fptr= &(b.method);  //error: cannot convert 'A::method' from type 
                           // 'void(A::)()' to type 'void (*)()'
    cout << A::fptr << endl;
    A::fptr= &(c.method);  //error: cannot convert 'A::method' from type  
                           //'void(A::)()' to type 'void (*)()'
    cout << A::fptr << endl;
    return 0;
}
 
     
     
    