I have the following class:
class A {
B m_data;
};
Also I have a function which needs B& as an argument.
How do I implement a conversion operator that can cast from const A& to B&?
I tried the following (derived from here):
operator B() const { return m_data; }
But that does not work, it says "no matching function call" when I want to call the function which needs B&.
EDIT: To clarify for what I am doing this: I use OpenCV and have implemented a Image class which is a wrapper for cv::Mat. I want to call cv::calcOpticalFlowSF which takes cv::Mat& as input and I have a const Image&.
EDIT2: It should look like this:
const Image OpticalFlowSF::getFlowImage(const Image & in1, const Image & in2) {
Image flow;
cv::calcOpticalFlowSF(in1, in2, flow, m_layers, m_averagingBlockSize, m_maxFlow);
return flow;
}