Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy Constructor needed

Status
Not open for further replies.

MarcoMB

Programmer
Oct 24, 2006
61
IT
i need to implement something similar...

CSpLine* CSdicap10Doc::AddSpLine(CArray<POINT,POINT>ControlPoints, CArray<POINT,POINT>Curvepoints)
{

CSpLine* pSpLine = new CSpLine(m_ControlPoints,m_CurvePoints);
m_oaSpLines.Add(pSpLine);

return pSpLine;
}

where ControlPoints and CurvePoints are

CArray <POINT,POINT> m_CurvePoints;
CArray <POINT,POINT> m_ControlPoints;

and m_oaSpLines is
CObArray m_ospLines;
The constructor is...

CSpLine::CSpLine(CArray<POINT,POINT>ControlPoints,CArray<POINT,POINT>CurvePoints)
{
m_ControlPoints = ControlPoints;
m_CurvePoints = CurvePoints;
}
The errors regards copy constructor and operator overloading...
error C2664: 'CSpLine::CSpLine' : cannot convert parameter 1 from 'class CArray<struct tagPOINT,struct tagPOINT>' to 'class CArray<struct tagPOINT,struct ta
gPOINT>'
No copy constructor available for class 'CArray<struct tagPOINT,struct tagPOINT>'
error C2582: 'CArray<struct tagPOINT,struct tagPOINT>' : 'operator =' function is unavailable

Can i solve the problem?
 
thanks...using Copy method the compiler don't give me the error
No copy constructor available for class 'CArray<struct tagPOINT,struct tagPOINT>'
error C2582: 'CArray<struct tagPOINT,struct tagPOINT>' : 'operator =' function is unavailable

but with the Add method continue to say
error C2664: 'CSpLine::CSpLine' : cannot convert parameter 1 from 'class CArray<struct tagPOINT,struct tagPOINT>' to 'class CArray<struct tagPOINT,struct ta
gPOINT>'

how can i resolve? How have to modify my contructor that now is...
CSpLine::CSpLine(CArray<POINT,POINT>ControlPoints,CArray<POINT,POINT>CurvePoints)
{
m_ControlPoints.Copy(ControlPoints);
m_CurvePoints.Copy(CurvePoints);
}
 
You should be passing the CArrays by const reference so the arguments aren't copied when being sent to the function.
 
thanks for help...it works...you think it's ok for serialize this type of CObArray(CObArray of CSpLine object made by CArray <POINT,POINT>)?
 
it seems not possible serializing CArray<POINT,POINT>...
void CSpLine::Serialize(CArchive &ar)
{
CObject::Serialize(ar);
if (ar.IsStoring())
ar<<m_ControlPoints<<m_CurvePoints;

if (ar.IsLoading())
ar>>m_ControlPoints>>m_CurvePoints;
}
what am i doing wrong?
 
i think to use serialization with CArray i must use hekper function SerializeElements...do u think so?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top