Puppet_Sock wrote:
> On May 7, 12:04 pm, Tim Frink <plfr...@[EMAIL PROTECTED]
> wrote:
>> Hi,
>>
>> I want to use a callback function together with
>> templates. Let's say I've this code:
>>
>> File a.h:
>>
>> class A
>> {
>> private:
>> template< typename T >
>> void func( bool( T::*f)(void) );};
>>
> [snips]
>
> Do you really want that private? That seems wrong for a callback.
Why? It would actually make sure that nobody except whoever gets
the pointer to that function, can call it. Not a bad idea for
a callback to be private.
> Also, do you really want it to be a template member function?
> Or do you want the class to be a template class? That is, do
> you want all the items, of various different types, that make
> use of this callback to use the same class A? It would appear
> you are trying to collect callbacks for more than one T in the
> same instance. Is that really what you want?
I wonder, why all those questions? Did it have anything to do
with the problem the OP experienced? Generally speaking, the
link error (this is what the OP's got, isn't it?) is because it
is a function template that is used in 'main' and its source is
not visible so that the compiler can generate the function. But
the design has really nothing to do with it, does it? Simply
tell the OP to place the definition in the header.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


|