That''s my problem:
Linking...
MainFrm.obj : error LNK2005: "public: __thiscall E3DVECTOR::E3DVECTOR(void)"(??0E3DVECTOR@@QAE@XZ) already defined in ChildFrm.obj
MainFrm.obj : error LNK2005: "public: __thiscall E3DVECTOR::E3DVECTOR(float,float,float)"(??0E3DVECTOR@@QAE@MMM@Z) already defined in ChildFrm.obj
First, I know #ifndef...#define...#endif !!
As you can see I use MFC. Everything works fine, if I make a class with the classwizard. But if I want to write my own classes then the lnk2005 error appears.
I have a MFC MDI app with the ChildFrm.cpp and MainFrm.cpp files.
In addition I have my own files etypes.cpp and etypes.h:
etypes.cpp:
#ifndef _ETYPES_CPP_
#define _ETYPES_CPP_
#include "../inc/etypes.h"
E3DVECTOR::E3DVECTOR()
{
}
E3DVECTOR::E3DVECTOR(float lx,float ly,float lz)
{
x=lx;
y=ly;
z=lz;
}
#endif
etypes.h:
#ifndef _ETYPES_H_
#define _ETYPES_H_
struct E3DVECTOR
{
union
{
struct
{
float x,y,z;
};
float v[3];
};
E3DVECTOR();
E3DVECTOR(float x,float y,float z);
~E3DVECTOR();
};
#endif
If I include etypes.cpp just in childfrm.cpp, it functions. But if I want to include in both (childfrm.cpp and mainfrm.cpp), the lnk2005 is once again on my screen.
Please Help!!!!!!!!!!
The problem of Object Oriented Programming:Everybody tells you how to use his classes, but nobody how not to do it !