Original Post
Guys, I have an issue with Inline Functions, consider the following header file for stack. //////////////////////////////////////////////////////////////////////////////////// // Stack.h #ifndef __STACK_H_INCLUDED__ #define __STACK_H_INCLUDED__ namespace Engine { template <class _Type> class CStack { public: __forceinline CStack(void); virtual ~CStack(void); private: // Data Needed for Stack }; } // This is where i can put the Destructor Body which works //template <class _Type> //Engine::CStack<_Type>::~CStack( void ) //{ //} #include "Stack.inl" #endif // __STACK_H_INCLUDED__ /////////////////////////////////////////////////////////////////////////////// // Stack.inl namespace Engine { template <class _Type> __forceinline CStack<_Type>::CStack(void) { // Allocate Memory } } /////////////////////////////////////////////////////////////////////////////// // Stack.cpp #include "Stack.h" namespace Engine { //-----------------------------------------------------------------------// template <class _Type> CStack<_Type>::~CStack(void) { // do the deletion here } //-----------------------------------------------------------------------// } //////////////////////////////////////////////////////////////////////////////////// Now the Problem, If i define the Destructor in the header file after the Class Difinition, i get a successfull compile, But if the Body of the Destructor is in the Stack.cpp file i get a Linker Error LNK2019. Now if i remove the Virtual Qualifier from the ~CStack(void),,, and define the function any where in header or inline or cpp, i get a successfull compile again,, what is going on? i can't understand all this . Please Note the Namespace "Engine" Used and also the __forcinline instead of inline, but they essentially bahave the same in my case. any kind of help would be greatly appriciated. .. waZim