Topic: Q: const member func returning a func ptr?
Author: plessel@fred.rtpnc.epa.gov (Todd Plessel)
Date: 12 Aug 1994 17:07:45 GMT Raw View
void func1() {} // Some global function.
class X
{
private:
void (*fp)(); // fp will point to a non-member function such as func1().
public:
X() { fp = 0; }
void call() const { (*fp)(); } // Call fp.
void set( void (*fp1)() ) { fp = fp1; } // Set fp.
void (*get())() const { return fp; } // Get fp.
// Problem:
// The get member function does not change 'this'.
// What is the correct syntax for declaring it as a const member function?
// (My compiler complains about the keyword const in front of the left brace.)
// Please e-mail the solution to plessel@vislab.epa.gov.
// Thank you.
};