Errors in passing a function my defined object
Code:
bool Board::placeShip(Ship whichShip)
{
//1 == Horizontal;
//0 == Vertical;
short int pathOK = 0;
short int length = whichShip->getLength(m_whichPlayer);
short int xCoord = whichShip->getXCoords(m_whichPlayer);
short int yCoord = whichShip->getYCoords(m_whichPlayer);
if (whichShip->getOrientation(m_whichPlayer))
{
for (short i = 0; i < length; i++)
{
if ((i + xCoord) > m_xWidth)
{
return 1; //Bad Placement
} else {
if (m_oceanArray[i + xCoord][yCoord] == 11)
{
if (pathOK == length)
{
m_oceanArray[i + xCoord]
[yCoord]
= whichShip->getNumber();
if (i == (length - 1))
{
return 0;
}
} else {
pathOK++;
if (pathOK == length)
{
i = -1;
}
}
} else {
return 1; //Bad Placement
}
}
}
} else {
for (short i = 0; i < length; i++)
{
if ((i + yCoord) > m_yHeight)
{
return 1; //Bad Placement
} else {
if (m_oceanArray[xCoord][i + yCoord] == 11)
{
if (pathOK == length)
{
m_oceanArray[xCoord]
[i + yCoord]
= whichShip->getNumber();
if (i == (length - 1))
{
return 0;
}
} else {
pathOK++;
if (pathOK == length)
{
i = -1;
}
}
} else {
return 1; //Bad Placement
}
}
}
}
return 1;
};
I've been through, and through this code.. I don't know what to do, I'll be passing this function an object of type ship, and it will be a pointer.. but trying to access its member functions from within the class is giving me errors; how else could I do this?