[LC++]Inlining with templated member functions

Chris Vine chris at cvine.freeserve.co.uk
Tue Jul 2 07:38:06 UTC 2002


On Monday 01 Jul 2002 9:18 am, Mark Phillips wrote:
> Hi,
>
> This list has been a bit quiet.  I have a question though...
>
> I defined a struct with a templated member function thus:
>
> struct MyStruct {
> ....
>    template<typename A> void put(A const& a);
> ....
> };
>
> and later did
>
> template<typename A>
> inline void put(A const& a) {
> .... // do something
> }

[snip]

You haven't correctly defined the scope.  Try

template<typename A>
inline void MyStruct::put(A const& a) {
.... // do something
}

It worked with your version defined in the class definition because the scope 
in that case is implicit.

Chris.





More information about the tuxCPProgramming mailing list