Taking an Address of a Member Function

Taking an Address of a Member Function

The name of an ordinary function is implicitly converted to its memory address. For example:

 typedef int (*pf) ();int func();pf=func; // OK, 'func' is implicitly converted to '&func'

However, member functions don’t behave this way. To take their address, you must precede the address-of operator to their qualified name:

 class A;typedef int (A::*pmf)();class A{  pmf p; //pointer to memberpublic: int func(); A() { p=&A::func;} //OK};

Note that the following code will cause a compilation error:

 A() { p=func;} // error, '&A::' missing 
Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular