Advertisement

Template based static member function?

Started by March 19, 2000 03:21 PM
0 comments, last by Jonjuan 24 years, 7 months ago
Well, I''m writing a few exception classes to organize my error handling code into a small class library, but I am having a problem creating a template based static member function. The class looks like this: class CErr{ public: CErr(LPTSTR lpErr){...} CErr(DWORD dwErr){...} template static void Throw(ARG argErr){ throw T(argErr); } }; class CErrDb : public CErr{ ... }; class CErrNet : public CErr{ ... }; Then I throw an exception like so: CErr::Throw(_T("USER NOT FOUND")); While compiling, I get the following error in VC6 - C:\Server\Db.cpp(54) : fatal error C1001: INTERNAL COMPILER ERROR (compiler file ''msc1.cpp'', line 1794) Please choose the Technical Support command on the Visual C++ Help menu, or open the Technical Support help file for more information Error executing cl.exe. If I move the function outside of the class, the code compiles correctly, and everything works well, but I''m wondering if templates are illegal for static member functions or if I''ve found a bug in the compiler, or if I''m doing something incorrectly? (chances are I''m doing something wrong, but who knows) Thanks in advance, Jon Stelly
FREAKING formatting... just forget it. I hate that there isn''t a way to turn off the formatting while posting to this Board. I used the code and /code tags, but that doesn''t work.

I don''t feel like spending 4 hours learning enough HTML to figure out how to display the greater than / less than / symbols without it using them as escape sequences.

Watch this work though:

Function Declaration / Definition:


template<>
static void Throw(ARG argErr){
throw T(argErr);
}


I then call the function like so:


CErr::Throw<>(_T("USER NOT FOUND"));


Oh well, like I said, just forget this thread.

This topic is closed to new replies.

Advertisement