我在MFC中定义了一个CLine类,其声明如下
class CLine
{
public:
CLine(CLine &line);
CColor c_Color;
CLine();
CPoint m_pntStart;
CPoint m_pntEnd;
CLine(CPoint pntStart,CPoint pntEnd,CColor color);
void DrawLine(CDC *pDC);virtual ~CLine();};
定义如下
#include "stdafx.h"
#include "GraphExp.h"
#include "Line.h"#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////CLine::CLine(CPoint pntStart,CPoint pntEnd,CColor color)
{
m_pntStart=pntStart;
m_pntEnd=pntEnd;
c_Color=color;}void CLine::DrawLine(CDC *pDC)
{
CPen newPen;
if( newPen.CreatePen( PS_DASH, 1, RGB(c_Color.m_nR,c_Color.m_nG,c_Color.m_nB) ) )
{
// Select it into the device context
// Save the old pen at the same time
CPen* pOldPen = pDC->SelectObject( &newPen );// Draw with the pen
pDC->MoveTo(m_pntStart);
pDC->LineTo(m_pntEnd);// Restore the old pen to the device context
pDC->SelectObject( pOldPen );
}
//CView::UpdateData();
}
CLine::CLine()
{
}
CLine::~CLine()
{
}CLine::CLine(CLine &line)
{
this->m_pntEnd=line.m_pntEnd;
this->m_pntStart=line.m_pntStart;
this->c_Color=line.c_Color;
}
在文档类中有一成员函数为
CLine CGraphExpDoc::GetLine(int index)
{
return m_vLines.at(index);
}
但是出现了如下错误
:\microsoft visual studio\vc98\include\xmemory(34) : error C2558: class 'CLine' : no copy constructor available
d:\microsoft visual studio\vc98\include\xmemory(66) : see reference to function template instantiation 'void __cdecl std::_Construct(class CLine *,const class CLine &)' being compiled
按f4后指向的内部函数是
template<class _T1, class _T2> inline
void _Construct(_T1 _FARQ *_P, const _T2& _V)
{new ((void _FARQ *)_P) _T1(_V); }void construct(pointer _P, const _Ty& _V)
{_Construct(_P, _V); }
class CLine
{
public:
CLine(CLine &line);
CColor c_Color;
CLine();
CPoint m_pntStart;
CPoint m_pntEnd;
CLine(CPoint pntStart,CPoint pntEnd,CColor color);
void DrawLine(CDC *pDC);virtual ~CLine();};
定义如下
#include "stdafx.h"
#include "GraphExp.h"
#include "Line.h"#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////CLine::CLine(CPoint pntStart,CPoint pntEnd,CColor color)
{
m_pntStart=pntStart;
m_pntEnd=pntEnd;
c_Color=color;}void CLine::DrawLine(CDC *pDC)
{
CPen newPen;
if( newPen.CreatePen( PS_DASH, 1, RGB(c_Color.m_nR,c_Color.m_nG,c_Color.m_nB) ) )
{
// Select it into the device context
// Save the old pen at the same time
CPen* pOldPen = pDC->SelectObject( &newPen );// Draw with the pen
pDC->MoveTo(m_pntStart);
pDC->LineTo(m_pntEnd);// Restore the old pen to the device context
pDC->SelectObject( pOldPen );
}
//CView::UpdateData();
}
CLine::CLine()
{
}
CLine::~CLine()
{
}CLine::CLine(CLine &line)
{
this->m_pntEnd=line.m_pntEnd;
this->m_pntStart=line.m_pntStart;
this->c_Color=line.c_Color;
}
在文档类中有一成员函数为
CLine CGraphExpDoc::GetLine(int index)
{
return m_vLines.at(index);
}
但是出现了如下错误
:\microsoft visual studio\vc98\include\xmemory(34) : error C2558: class 'CLine' : no copy constructor available
d:\microsoft visual studio\vc98\include\xmemory(66) : see reference to function template instantiation 'void __cdecl std::_Construct(class CLine *,const class CLine &)' being compiled
按f4后指向的内部函数是
template<class _T1, class _T2> inline
void _Construct(_T1 _FARQ *_P, const _T2& _V)
{new ((void _FARQ *)_P) _T1(_V); }void construct(pointer _P, const _Ty& _V)
{_Construct(_P, _V); }
解决方案 »
- MFC 列表框控件 字符串操作
- 运用钩子函数实现软件的自动安装需要那些注意事项,谁实现过!!
- codeproject上2005以前的例子几乎都不见啦,怎么回事?
- 遇到一个调用自定义的类的问题,请帮忙看看,谢谢!
- 非绝顶高手不能解决的界面问题?CListView 编辑问题......
- 请高手看看我的问题,创建窗口!
- udp传输文件的问题,发送方发送很快,但接收方接收缓慢,尤其接收方通过拨号上网的时候更慢,甚至接收不完
- WH_GETMESSAGE 钩子, 为什么无法丢弃消息
- CryptAcquireContext的速度问题
- 如何获取(POP3)协议邮件中的附件
- 请教一个关于socket发送struct数据的问题
- 橡皮筋划线中如何显示颜色啊?
CLine& CGraphExpDoc::GetLine(int index)
{
return m_vLines.at(index);
}
改为
CLine(const CLine &line);
发到我邮箱