ejlouw ejlouw - 3 months ago 11
C++ Question

C++ function thinks pointer argument is pointer reference

When compiling a library I get the following error related to the function below:


error: no matching function for call to ‘Factor::inplaceCancel(const
Factor*&)’


I don't understand why the
const Factor* rhsFPtr
is being treated as a
const Factor*&
.
Could anyone perhaps help me with this?

void InplaceCancelFF::inplaceProcess(FactorisedFactor* lhsPtr, const Factor* rhsFPtr){
lhsPtr->factorPtrs[0]->inplaceCancel(rhsFPtr);
...
}
//In the abstract Factor Class:
virtual void inplaceCancel(const Factor* rhsPtr,FactorOperator* procPtr) = 0;
//In the child class:
inline void inplaceCancel(const Factor* rhsPtr, FactorOperator* procPtr = 0);

Answer

The declaration in the base class has no second default parameter (procPtr). So this gets ignored in the child class declarations.

You need to provide 2 arguments to the function for this to work (or at a default to the base declaration)

Comments