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

Function template inside of class template

P: n/a
Consider this:

----SNIP----
template<typename T>
class
foo
{
public:

template<typename Svoid f(S s) { }
};

// ???

// template<typename T>
// void
// foo<T>::f<S>(S s)
// {

// }

int main()
{
foo<intf;

f.f<float>(1.0f);

return 0;
}
----SNIP----

That code works, but how do I write the function definition outside of the
class? I cannot get the code to compile, always some syntax error.

Arne

--
[--- PGP key FD05BED7 --- http://www.root42.de/ ---]
Dec 19 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
The code below works:
template<typename T>
class
foo
{
public:

template<typename Svoid f(S s);
};

// ???

template<typename T>
template<typename S>
void
foo<T>::f(S s)
{

}

int main()
{
foo<intf;

f.f<float>(1.0f);

return 0;
}
--
[--- PGP key FD05BED7 --- http://www.root42.de/ ---]
Dec 19 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.