If I remove the 'friend' and leave the 'float' the project builds but I am not confident it is doing what it should.
That is definitely not the correct thing to do.
This is the relevant issue.
A friend declaration with default arguments must also be a definition.
So you have some choices as to how to fix this. You can either move the definition of this function into the friend declaration:
friend float
DistBetweenModels (ShapeModel* pModel1, ShapeModel* pModel2,
enEvalType nEvalType = ET_EyeDist, enDistType nDistType = DT_Max)
{
// function definition goes here
}
Or you could remove the default arguments in the friend declaration:
friend float
DistBetweenModels (ShapeModel* pModel1, ShapeModel* pModel2,
enEvalType nEvalType, enDistType nDistType);
But you should make sure that there's an earlier, non-friend declaration at namespace scope of this function that includes the default arguments.
I would choose the second solution; defining the function outside the class and moving the default arguments there. This is because there are some subtleties with name-lookup for friend functions which are defined inline. Inline friend functions should only be used for functions that are expected to be called via ADL (such as operator overloads).
This assumes that the function does need to be a friend. If not then you can just remove this friend declaration.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…