Re: Calling a static class-member template function
* Olumide:
Hi -
I've got a static class member function
MyClass{
public:
template <typename T> static void converter( list<T > &, vector<T
& );
};
template <typename T> void VTK_Writer::converter( list<T > &lst,
vector<T > &vec )
{
// does weird and wonderful stuff
}
MyClass != VTK_Writer
Also, if this code is in a header file, then it's not a good idea to
have "using namespace std;" in a header file.
If this code is not in a header file, but in a separately compiled
implementation file, then see FAQ item 35.12 "Why can't I separate the
definition of my templates class from it's declaration and put it inside
a .cpp file?" e.g. at <url:
http://www.parashift.com/c++-faq-lite/templates.html#faq-35.12>.
It compiles well. However, when I try to call/use this function as
such,
main( )
'main' must have result type 'int'.
{
list<int > A;
vector<int > B;
MyClass::converter( A, B ); // E R R O R
}
The Microsoft C++ compiler "rewards" me with the linker error LNK2019.
For the meaning of error codes see your compiler/linker's documentation.
Presumably the linker also spit out a textual message.
It would have been a good idea to reproduce that message, although it's
not difficult to guess that it would involve words like "undefined" or
"missing".
What am I doing wrong?
See above.
PS: is it a static class member function template OR a static class
member template function? ;-)
I don't think it's meaningful to make that distinction (there is a myth
that experts know what is what, but that's just a myth), but for the
definition of the function I'd prefer the first.
Cheers, & hth.,
- Alf
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?