简体   繁体   中英

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);

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)

Thanks for the help guys. There was some function overloading in the base class that I did not see (I'm editing someone else's code). I changed the pointer type to match one of the other functions and that resolved the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM