自定义结构体数组无法用Copy或Append整体赋值,怎么办?
八月 3, 2007
发表在: java
c:\program files\microsoft visual studio\vc98\mfc\include\afxtempl.h(86) : error c2679: binary = : no operator defined which takes a right-hand operand of type const struct tagtrainstoptime (or there is no acceptable conversion)
(*pdest++ = *psrc++;)//指向此处语句。
自定义结构体:
typedef struct tagtrainstoptime
{
float fupendx;
float fdnendx;
float fdndummyendx;
carray<float,float> arrstoptimesx;//存储x坐标即时间
carray<cstring,cstring> arrstoptimes;
tagtrainstoptime()
{
fupendx=0;
fdnendx=0;
fdndummyendx=0;
arrstoptimesx.setsize(0);
arrstoptimes.setsize(0);
};
tagtrainstoptime(tagtrainstoptime& t)
{
fupendx=t.fupendx;
fdnendx=t.fdnendx;
fdndummyendx=t.fdndummyendx;
arrstoptimesx.copy(t.arrstoptimesx);
arrstoptimes.copy(t.arrstoptimes);
};
void operator=(tagtrainstoptime& t)
{
fupendx=t.fupendx;
fdnendx=t.fdnendx;
fdndummyendx=t.fdndummyendx;
arrstoptimesx.copy(t.arrstoptimesx);
arrstoptimes.copy(t.arrstoptimes);
};
}trainstoptimes;
carray<trainstoptimes,trainstoptimes> train1;
carray<trainstoptimes,trainstoptimes> train2;
train2.copy(train1);或
train2.append(train1);均会产生该问题。
原来连add函数都无法使用,在未增加自定义构造函数和=重载函数之前。
电脑软件技术推荐:
怀疑你等号两边的类型不一样,两个相同类型的是没有问题的
.
No comments in this entry