template/member function puzzle

G

Glen Able

Not sure if this a dumb syntax error, or if there some more subtle reason
why this doesn't work:

template <class ObjT> class Foo
{
typedef bool (ObjT::*TestFunction)();

public:
void Bar( ObjT* pObj,
TestFunction fn)
{
if (pObj->*fn()) // ERROR HERE : "term does not evaluate to a
function"
{

}
}
};

Any thoughts?

ta,
G.A.
 
S

Sumit Rajan

Glen Able said:
Not sure if this a dumb syntax error, or if there some more subtle reason
why this doesn't work:

template <class ObjT> class Foo
{
typedef bool (ObjT::*TestFunction)();

public:
void Bar( ObjT* pObj,
TestFunction fn)
{
if (pObj->*fn()) // ERROR HERE : "term does not evaluate to a
function"

This should "work":
if (pObj->fn())

or:
if ((*pObj->fn)())

Regards,
Sumit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,201
Messages
2,571,049
Members
47,654
Latest member
LannySinge

Latest Threads

Top