Hopefully the last major question on this project...
I know what this error typically means - that the linker couldn't find the function definition that you used and declared. But I'm confused. I have two cpp files (driver and MemoryManager) and a header file (MemoryManager). part of driver.cpp's main():
Now in the header file:Code:// previously defined simple class called MyTest MemoryManager::Mgr mem( MemoryManager::printall ); MyTest* foo = mem.alloc<MyTest>();
And in the definition file:Code:class Mgr { public: // some snippage, I think these are the relevant parts template< class T > T* alloc( int = 1 ); protected: pvomap allPtrs; };
This function gets called and appears to me to be defined. Using Borland 5.5.1, I run:Code:template<class T> T* Mgr::alloc( int a ) { T* ptr = new T[a]; allPtrs[ ptr ] += a; return ptr; }
bcc32 driver.cpp MemoryManager.cpp
It compiles correctly but generates the linker error:
Unresolved external 'MyTest * MemoryManager::Mgr::alloc<MyTest>(int)' referenced from DRIVER.OBJ. I cannot figure out why I'm getting this - the compiler doesn't complain that I've left a member function undefined or that I've defined one that doesn't exist, and as near as I can tell the prototypes match. Can anybody see why it will not work? TIA!