By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,493 Members | 1,289 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,493 IT Pros & Developers. It's quick & easy.

Taking address of member template function.

P: n/a
Hello newsgroup,

I try to take the address of a member template function, but I can't
succeed. My copy of Bjarne Stroupstrup says nothing against this, so I
guess that what I want to achive is not beyond the possibilities of C++,
but beyond the abilities of my compiler (Visual C++ 6.0). Following code
won't compile (error C2039: 'SomeFunc' : Is no element of '`global
namespace''). Any suggestions would be highly appreciated.

class TestClass
{
public:
template<int t_ID>
void SomeFunc ()
{}
};

void (TestClass::*pFuncPtr) () = TestClass<0>::SomeFunc;

Thanks in advance,
Stuart
Feb 13 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Feb 13, 10:16 am, Stuart Redmann <DerTop...@web.dewrote:
I try to take the address of a member template function, but I can't
succeed. My copy of Bjarne Stroupstrup says nothing against this, so I
guess that what I want to achive is not beyond the possibilities of C++,
but beyond the abilities of my compiler (Visual C++ 6.0). Following code
won't compile (error C2039: 'SomeFunc' : Is no element of '`global
namespace''). Any suggestions would be highly appreciated.

class TestClass
{
public:
template<int t_ID>
void SomeFunc ()
{}

};

void (TestClass::*pFuncPtr) () = TestClass<0>::SomeFunc;
Two suggestions:

1. Your syntax is wrong. Change the last line to:

void (TestClass::*pFuncPtr) () = &TestClass::SomeFunc<0>;

2. Get a new compiler - Visual C++ 6.0 is horribly out of date.

Best regards,

Tom

Feb 13 '07 #2

P: n/a
Thomas Tutone wrote:
On Feb 13, 10:16 am, Stuart Redmann <DerTop...@web.dewrote:
>>I try to take the address of a member template function, but I can't
succeed. My copy of Bjarne Stroupstrup says nothing against this, so I
guess that what I want to achive is not beyond the possibilities of C++,
but beyond the abilities of my compiler (Visual C++ 6.0). Following code
won't compile (error C2039: 'SomeFunc' : Is no element of '`global
namespace''). Any suggestions would be highly appreciated.

class TestClass
{
public:
template<int t_ID>
void SomeFunc ()
{}

};

void (TestClass::*pFuncPtr) () = TestClass<0>::SomeFunc;


Two suggestions:

1. Your syntax is wrong. Change the last line to:

void (TestClass::*pFuncPtr) () = &TestClass::SomeFunc<0>;
That is what I was afraid of: With this syntax I get
fatal error C1001: INTERNAL COMPILER- ERROR
2. Get a new compiler - Visual C++ 6.0 is horribly out of date.
I will. Honestly.

Thanks,
Stuart
Feb 13 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.