error LNK2005
-
Hoi zäme,
ich habe ein kleineres Problem mit Visual C++ 2008 Express von Microsoft. Der Code kann nicht gelinkt werden und die Ausgabe ist:
Compiling... chainnode.cpp main.cpp nodecontent.cpp Generating Code... Compiling manifest to resources... Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0 Copyright (C) Microsoft Corporation. All rights reserved. Linking... nodecontent.obj : error LNK2005: "public: __thiscall INTEGER::INTEGER(int)" (??0INTEGER@@QAE@H@Z) already defined in main.obj nodecontent.obj : error LNK2005: "public: int __thiscall INTEGER::get(void)" (?get@INTEGER@@QAEHXZ) already defined in main.obj nodecontent.obj : error LNK2005: "public: void __thiscall INTEGER::set(int)" (?set@INTEGER@@QAEXH@Z) already defined in main.obj nodecontent.obj : error LNK2005: "public: int __thiscall INTEGER::compare(class INTEGER *)" (?compare@INTEGER@@QAEHPAV1@@Z) already defined in main.obj C:\Dokumente und Einstellungen\Administrator\Eigene Dateien\Visual Studio 2008\Projects\chainlist\Debug\chainlist.exe : fatal error LNK1169: one or more multiply defined symbols found Build log was saved at "file://c:\Dokumente und Einstellungen\Administrator\Eigene Dateien\Visual Studio 2008\Projects\chainlist\chainlist\Debug\BuildLog.htm" chainlist - 5 error(s), 0 warning(s)
Der Code habe ich unter Gentoo Linux mit GCC 4.1.2 entwickelt wo er auch brav tut! Unter Windows 2003 Server tut dann das allerdings nicht mehr. Aus dem MSDN entnehme ich, dass es sich um eine Variablendeklaration handeln könnte. Allerdings kann das nicht sein, da ich keinerlei Header verwende. (Ja, schlagt mich!)
Dependency: main.cpp -> chainnode.cpp -> nodecontent.cpp Dateien werden mit #include eingefügt.
template <class T> class chainnode { public: chainnode(chainnode<T> * pLeftNode, chainnode<T> * pRightnode); chainnode(chainnode<T> * pLeftNode, chainnode<T> * pRightNode, bool Leaf); ~chainnode(); // Child nodes chainnode<T> * left_node() { return ptr_left_node; } chainnode<T> * right_node() { return ptr_right_node; } void set_left_node (chainnode *left) { ptr_left_node = left; } void set_right_node (chainnode *right) { ptr_right_node = right; } // Operations on nodes void insert(T* node); //chainnode<T> * search( T* content ); // Operations on content void setcontent(T* content); T* getcontent (); int showcontent (); bool contentexist(T* content); void set_is_leaf(bool is_leaf); private: chainnode<T> *ptr_left_node; chainnode<T> *ptr_right_node; T* node_content; bool imLeaf; };
template <class T> class chainnode { public: chainnode(chainnode<T> * pLeftNode, chainnode<T> * pRightnode); chainnode(chainnode<T> * pLeftNode, chainnode<T> * pRightNode, bool Leaf); ~chainnode(); // Child nodes chainnode<T> * left_node() { return ptr_left_node; } chainnode<T> * right_node() { return ptr_right_node; } void set_left_node (chainnode *left) { ptr_left_node = left; } void set_right_node (chainnode *right) { ptr_right_node = right; } // Operations on nodes void insert(T* node); //chainnode<T> * search( T* content ); // Operations on content void setcontent(T* content); T* getcontent (); int showcontent (); bool contentexist(T* content); void set_is_leaf(bool is_leaf); private: chainnode<T> *ptr_left_node; chainnode<T> *ptr_right_node; T* node_content; bool imLeaf; };
Hat einer eine Idee voran das liegt? Danke!