Z
zahy[dot]bnaya[At]gmail[dot]com
Hello,
I am using MSVC 6.
I organize my files so that Class definitions are in a .H files and the
implementation is on a .cpp files.
so my main file looks like that:
#include "foo.cpp"
#include "bar.cpp"
void main(int argc,char* argv[])
{
}
Every cpp file is including its H file.
for example the foo.cpp file would have
#include "foo.h"
on its first lines.
Every .h file is wrapped with a preprocessor indicators :
#ifndef __FOO__H__
#define __FOO__H__
class foo{
....
};
#endif /*__FOO__H__*/
I noticed I tend to get enormous amount of linkage errors like below:
error LNK2005: "public: __thiscall Component::Component(void)"
(??0Component@@QAE@XZ) already defined in linkedlist.obj
tmp.obj : error LNK2005: "public: __thiscall Component::Component(int)"
(??0Component@@QAE@H@Z) already defined in linkedlist.obj
tmp.obj : error LNK2005: "public: __thiscall
Component::~Component(void)" (??1Component@@QAE@XZ) already defined in
linkedlist.obj
why is this happening? I also noticed that it does not occur on all of
my project but only once in a while.. why is that?
There must be a simple answer to that...
Am I doing something wrong? is this a good organization of code?
Thanks.
I am using MSVC 6.
I organize my files so that Class definitions are in a .H files and the
implementation is on a .cpp files.
From my main file (where the main() is) I include only the cpp files
so my main file looks like that:
#include "foo.cpp"
#include "bar.cpp"
void main(int argc,char* argv[])
{
}
Every cpp file is including its H file.
for example the foo.cpp file would have
#include "foo.h"
on its first lines.
Every .h file is wrapped with a preprocessor indicators :
#ifndef __FOO__H__
#define __FOO__H__
class foo{
....
};
#endif /*__FOO__H__*/
I noticed I tend to get enormous amount of linkage errors like below:
error LNK2005: "public: __thiscall Component::Component(void)"
(??0Component@@QAE@XZ) already defined in linkedlist.obj
tmp.obj : error LNK2005: "public: __thiscall Component::Component(int)"
(??0Component@@QAE@H@Z) already defined in linkedlist.obj
tmp.obj : error LNK2005: "public: __thiscall
Component::~Component(void)" (??1Component@@QAE@XZ) already defined in
linkedlist.obj
why is this happening? I also noticed that it does not occur on all of
my project but only once in a while.. why is that?
There must be a simple answer to that...
Am I doing something wrong? is this a good organization of code?
Thanks.