DWit
December 14th, 2002, 02:22 AM
I have been working on a little project and keep getting this error when I use the code that follows. If anyone knows why this happens (using vc++.net compiler) please let me know. The error goes away when I use pass by value instead, but since I am passing a struct, I want to use pass by reference.
ERROR:
error C2664: 'CSquareInfo::RemovePiece' : cannot convert parameter 1 from 'PIECEDATA *__w64 ' to 'PIECEDATA &'
///////////////////////////////////////////////////////////////////////////////
HEADER FILE - function declaration:
bool RemovePiece(PIECEDATA &pieceData); //PIECEDATA is a struct
////////////////////////////////////////////////////////////////////////////////
IMPLIMENTATION FILE - function
bool CSquareInfo::RemovePiece(PIECEDATA &pieceData)
{
PIECEDATA empty;
if(pieceData.COLOR == LIGHT && pieceData.ID == vLight[numLight - 1].id)
{
vLight[numLight - 1].SetPieceData(empty);
numLight--;
numTotal--;
return true; // successful
}
else if(pieceData.COLOR == DARK && pieceData.ID == vDark[numDark - 1].id)
{
vDark[numDark - 1].SetPieceData(empty);
numDark--;
numTotal--;
return true; // successful
}
else
{
return false; // unsuccessful
}
}
///////////////////////////////////////////////////////////////////////////////
CALL THAT CAUSES ERROR:
object.RemovePiece(&pData1);
note: object is of type CSquareInfo and pData1 is a PIECEDATA struct and is not a pointer (despite the p before Data1).
ERROR:
error C2664: 'CSquareInfo::RemovePiece' : cannot convert parameter 1 from 'PIECEDATA *__w64 ' to 'PIECEDATA &'
///////////////////////////////////////////////////////////////////////////////
HEADER FILE - function declaration:
bool RemovePiece(PIECEDATA &pieceData); //PIECEDATA is a struct
////////////////////////////////////////////////////////////////////////////////
IMPLIMENTATION FILE - function
bool CSquareInfo::RemovePiece(PIECEDATA &pieceData)
{
PIECEDATA empty;
if(pieceData.COLOR == LIGHT && pieceData.ID == vLight[numLight - 1].id)
{
vLight[numLight - 1].SetPieceData(empty);
numLight--;
numTotal--;
return true; // successful
}
else if(pieceData.COLOR == DARK && pieceData.ID == vDark[numDark - 1].id)
{
vDark[numDark - 1].SetPieceData(empty);
numDark--;
numTotal--;
return true; // successful
}
else
{
return false; // unsuccessful
}
}
///////////////////////////////////////////////////////////////////////////////
CALL THAT CAUSES ERROR:
object.RemovePiece(&pData1);
note: object is of type CSquareInfo and pData1 is a PIECEDATA struct and is not a pointer (despite the p before Data1).