我在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); }