hi,
I have a rudimentary stack-class implemented in C++ which was working fine until I decided to pull the declaration out into a header file. I now have two files - a header file and a definition file (also containing main()).
a snippet of the header is as follows:
And a snippet of the definition is as:
and the unfortunate output is:
So - again - this worked fine when the definition and declarations were together in one file (i.e. everything was inline). Something with how I'm defining my non-inline functions isn't ok, and after staring at it for a while I'm still not sure what it is.
thank you very much for any help,
dora c
I have a rudimentary stack-class implemented in C++ which was working fine until I decided to pull the declaration out into a header file. I now have two files - a header file and a definition file (also containing main()).
a snippet of the header is as follows:
Code:
template <class T>
class mSTACK
{
public:
...
T pop();
...
protected:
deque<T> dStack;
}
Code:
...
template <typename T>
T mSTACK<typename T>::pop()
{
T Tdata;
if ( dStack.empty() )
{
throw ReadEmptyStack();
};
Tdata = dStack.back();
dStack.pop_back();
return Tdata;
}
...
int main()
{
mSTACK<int>* csStack = new mSTACK<int>;
...
int ia = 0;
csStack->push( ia );
cout << "value1 is: ."
<< csStack->pop()
<< "."
<< endl;
Code:
/out:mSTACK.exe
mSTACK.obj
libcp.lib(locale.obj) : error LNK2005: "public: static class std::locale::id std::num_put<char,class std::ostreambuf_iterator<char,struct std::char_traits<char> > >::id" (?id@?$num_put@DV?$ostreambuf_iterator@DU?$char_traits@D@std@@@std@@@std@@2V0locale@2@A) already defined in mSTACK.obj
libcp.lib(locale.obj) : error LNK2005: "public: static class std::locale::id std::numpunct<char>::id" (?id@?$numpunct@D@std@@2V0locale@2@A) already defined in mSTACK.obj
mSTACK.exe : fatal error LNK1169: one or more multiply defined symbols found
thank you very much for any help,
dora c