Hi. I'm working on a project for school with data structures in Visual C++. I got my code compiling just fine earlier today, and took it home and it no longer works. Both machines I've been working on use Visual Studio 2008. Here's the text of the error.
I'm not sure if this might have anything to do with it, but my program has 3 main classes: AVL, which inherits from BST, which inherits from SearchableADT. These are templated classes.
BST.obj : error LNK2005: "public: __thiscall BST,class std::allocator > >::BST,class std::allocator > >(void)" (??0?$BST@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@@QAE@XZ) already defined in AVL.obj
I'm at a complete loss for what to do. I've poked around on a few forums, looked at the MSDN page, and nothing's been able to fix it.
One thing I noticed mentioned on a site that I forgot was to have #ifndef/#define for my AVL. I created a fresh project and copy and pasted all my code in with this addition, and I'm still getting the same error though. I've looked over my code to verify that I'm not doing multiple includes of libraries. I'm at a loss for what to do from here though.
Thank you for any help you can provide, and sorry in advance if I left out something important.
Edit: I'm not sure 100% by what you mean with inline, trying to do some looking now. I do have a seperate cpp where I define the actual functions. Would the inline thing in Greg's answer still apply?
MSN, I'm afraid I didn't understand your answer. As for multiple copies of the default constructor, I do have
BST<int>::BST()
{
root = new Node<int>;
}
BST<string>::BST()
{
root = new Node<string>;
}
I'm not sure if that's what you were talking about, or if that might be the issue. My header file only has BST();, nothing for the int or string template. I have those definitions in my cpp because my instructor said they were necessary for the templated class.
Thank you very much