Hi all... just making an introductory program using linked lists and I am having troubles compiling... getting these messages
1>main.obj : error LNK2005: "public: __thiscall CUnitList::CUnitList(void)" (??0CUnitList@@QAE@XZ) already defined in civil.obj
1>main.obj : error LNK2005: "public: int __thiscall CUnitList::GetNodeCount(void)const " (?GetNodeCount@CUnitList@@QBEHXZ) already defined in civil.obj
1>main.obj : error LNK2005: "public: int __thiscall CUnitList::GetUnitCount(void)const " (?GetUnitCount@CUnitList@@QBEHXZ) already defined in civil.obj
Here is my code
#ifndef civil_h
#define civil_h
#include <string>
using namespace std;
class CUnitList
{
public:
//Member Functions
CUnitList();
~CUnitList();
int GetNodeCount() const;
int GetUnitCount() const;
void InsertUnit(string);
void Print() const;
I wish people would take time and post their code accurately and also use the code tags.
The following statement are somewhat suspicious when seen in an implementation (.cpp) file
1 2
#ifndef CUnitList_cpp
#define CUnitList_cpp
.
Have you got a #include "CUnitList.cpp" directive in main.cpp.
Multiple compilation of source files casued by including source files in other source files is usually the cause of this problem