Hi,
I received the following error message while using a CTypedPtrArray as typedef. Using the VC++6. I include here the complete code. The program is called CMini:
in MiniDoc.h:
#include <afxtempl.h>
#include <afxwin.h>
#include <afxext.h>
class Cline: public CObject
{
protected:
int m_x1,m_y1,m_x2,m_y2;
public:
Cline(int x1,int y1,int x2,int y2)
{
m_x1 = x1;
m_y1 = y1;
m_x2 = x2;
m_y2 = y2;
}
void Draw(CDC *pDC);
};
typedef CTypedPtrArray<CObArray, Cline*> m_LineArray;
Class CMiniDoc: public CDocument
public:
void AddLine(int x1,int y1, int x2, int y2);
Cline *GetLine(int Index);
int GetNumLines();
*********************************************
MiniDoc.CPP
void CMiniDoc::AddLine(int x1, int y1, int x2, int y2)
{
int x;
Cline *Pline = new Cline(x1,y1,x2,y2);
x = m_LineArray.Add(Pline);
}
Thanks in advance for your help

C2275 with CTypedPtrArray
jheske
I defined the CLineArray in the Doc.h & defined m_LineArray in Doc.cpp
Thanks
bruce_heath
You are defining a new type named m_LineArray:
typedef CTypedPtrArray<CObArray, Cline*> m_LineArray;
This is a type not a variable or member.
Declare a type in this way:
typedef CTypedPtrArray<CObArray, Cline*> CLineArray;
Use this new type in the document by adding the variable
CLineArray m_LineArray;
BTee
akortz
Thanks for your reply, I've made the change, but I received the following error:
MiniDoc.obj : error LNK2005: "class CTypedPtrArray<class CObArray,class Cline *> m_LineArray" ( m_LineArray@@3V $CTypedPtrArray@VCObArray@@PAVCline@@@@A) already defined in Mini.obj
MiniView.obj : error LNK2005: "class CTypedPtrArray<class CObArray,class Cline *> m_LineArray" ( m_LineArray@@3V $CTypedPtrArray@VCObArray@@PAVCline@@@@A) already defined in Mini.obj
Debug/Mini.exe : fatal error LNK1169: one or more multiply defined symbols found
Thanks