Re: [Dev-C++] Template member function (C++ obviously)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Tom C. <jat...@nt...> - 2003-07-27 17:26:11
|
"P.D. van Zelst" <pa...@my...> writes: > I'm trying to implement a pointer-to-member callback function in one of > my classes, and I finally seem to have the syntax right. I have a member > function whose prototype looks like this: > > template<typename T> void Parse(const std::string& strFile, T* pClass, > bool (T::* pCB)(const ConfigLine&)) > > It's a member function of a non-template class ConfigParser. When I try > to use this function however, I get a linker error. "[Linker error] > undefined reference to `void ConfigParser::Parse<Config>(std::string > const&, Config*, bool (Config::*)(ConfigLine const&))'" Try placing the definition of ConfigParser::Parse in a separate header file, which you should then #include at the bottom of the header file containing the class definition of ConfigParser. It means more must be recompiled when either header file is changed, but it's the only solution I've found to this most annoying of problems. I understand the C++ 'export' keyword is designed to alleviate the problem, but neither GCC nor Visual C++ currently supports it. --Tom |