Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

no operator = && copy constructor available?

36 views
Skip to first unread message

Maarten Troost

unread,
Nov 30, 2000, 3:00:00 AM11/30/00
to
HI,

i am new to MFC and try to save some work using MFC.
I created this function :

void CSegmentationDoc::SegmentImage(CRGBImg *img, CString segFileName)
{
int i;
file://region growing
typedef struct {int group; bool visited;} Vpoint;
CArray<BOOL,BOOL> shadowimg;
POINT p1;
POINT p2;
int group=0;
typedef CList<POINT,POINT> segment; file://reason of
CArray<segment,segment*> segments; file://error 1
segment reg;

for(i=img->Height(); index>0;i--)
for(int j=img->Width();index>0;j--)
{
if(!(shadowimg[i,j]) && Edge(img,i,j))
{
segments.SetAt(++group, new segment); file://reason of error 2
p1.x=i;
p1.y=j;
reg.AddHead(p1);
while (!reg.IsEmpty())
{
p1=reg.RemoveTail();
if (Edge(img,p1.x,p1.y))
segments.GetAt(group).AddHead(p1);
p2.x=p1.x+1;
p2.y=p1.y;
if(Different(img->GetPixel(p1.x,p1.y),img->GetPixel(p2.x,p2.y)))
{
shadowimg[p2.x,p2.y]=TRUE;
reg.AddHead(p2);
}
}
}
}
}


Of course this is not all of it, i just want to compile this and then some
strange errors occured :


ERROR 1
e:\microsoft visual studio\vc98\mfc\include\afxtempl.h(255) : error C2558:
class 'CList<struct tagPOINT,struct tagPOINT>' : no copy constructor
available
e:\microsoft visual studio\vc98\mfc\include\afxtempl.h(1566) : while
compiling class-template member function 'class CList<struct tagPOINT,struct
tagPOINT> __thiscall CArray<class CList<struct tagPOINT,struct
tagPOINT>,class CList<struct tag
POINT,struct tagPOINT> *>::GetAt(int) const'

ERROR 2
e:\microsoft visual studio\vc98\mfc\include\afxtempl.h(259) : error C2582:
'CList<struct tagPOINT,struct tagPOINT>' : 'operator =' function is
unavailable
e:\microsoft visual studio\vc98\mfc\include\afxtempl.h(1566) : while
compiling class-template member function 'void __thiscall CArray<class
CList<struct tagPOINT,struct tagPOINT>,class CList<struct tagPOINT,struct
tagPOINT> *>::SetAt(int,cla
ss CList<struct tagPOINT,struct tagPOINT> *)'


Since i work with VC6, MSDN reported that this is due to a private
declaration of the copy constructor. Than these are errors on the MFC!! I
think MFCare well debugged enough to ensure that these errors are due to a
"mis-use" of the CArray/CList template. If i mark certain lines as comments
the errors disappear. I marked those lines with file://reason of error ...

Any whizzkid available?

THNX

Maarten Troost

Andy Hassall

unread,
Nov 30, 2000, 3:00:00 AM11/30/00
to
On Thu, 30 Nov 2000 20:30:28 GMT, Maarten Troost wrote:

>i am new to MFC and try to save some work using MFC.
>
>I created this function :

>ERROR 1
>e:\microsoft visual studio\vc98\mfc\include\afxtempl.h(255) : error C2558:
>class 'CList<struct tagPOINT,struct tagPOINT>' : no copy constructor
>available
> e:\microsoft visual studio\vc98\mfc\include\afxtempl.h(1566) : while
>compiling class-template member function 'class CList<struct tagPOINT,struct
>tagPOINT> __thiscall CArray<class CList<struct tagPOINT,struct
>tagPOINT>,class CList<struct tag
>POINT,struct tagPOINT> *>::GetAt(int) const'
>
>ERROR 2
>e:\microsoft visual studio\vc98\mfc\include\afxtempl.h(259) : error C2582:
>'CList<struct tagPOINT,struct tagPOINT>' : 'operator =' function is
>unavailable
> e:\microsoft visual studio\vc98\mfc\include\afxtempl.h(1566) : while
>compiling class-template member function 'void __thiscall CArray<class
>CList<struct tagPOINT,struct tagPOINT>,class CList<struct tagPOINT,struct
>tagPOINT> *>::SetAt(int,cla
>ss CList<struct tagPOINT,struct tagPOINT> *)'
>
>Since i work with VC6, MSDN reported that this is due to a private
>declaration of the copy constructor. Than these are errors on the MFC!! I
>think MFCare well debugged enough to ensure that these errors are due to a
>"mis-use" of the CArray/CList template. If i mark certain lines as comments
>the errors disappear. I marked those lines with file://reason of error ...

This looks like it's exactly what it looks like, if you see what I mean.

There's no assigment operator or copy constructor for CList objects, so
you can't have a CArray of CList objects. You could have a CArray of
pointers to CList objects though, I suppose, but that's messier. The MFC
collections classes aren't exactly the best designed classes in the world.

The STL classes (Standard Template Library) have considerable advantages,
including the fact that they're a standard part of the C++ language,
rather than an add-on like MFC. The documentation, in VC5.0 at least, for
the STL is pretty poor, but there are plenty of good sources of
documentation out on the net.

For an example, the STL version of the types you wanted would be:

typedef std::list<POINT> segment;
std::vector<segment> segments;

or even just:

std::vector<list<POINT> > segments;

--
Andy Hassall (an...@andyh.org) icq(5747695) http://www.andyh.org
http://www.andyh.uklinux.net/space - disk usage analysis tool

0 new messages