Possible Duplicate:
Overloading by return type
Is it possible to overload only the output of a function. Say for example i have a function that can return a pose in two different ways. A 6DOF pose or a homogenous transform matrix. So i would have two functions:
Eigen::Vector6f pose();
and
Eigen::Matrix4d pose();
Is it ok to overload the only the output?
If I do then how will the compiler know which function to use?
Can it tell when I do this:
Eigen::Matrix4d poseHolder = pose();
To use the second function? If not is there a way to accomplish this without just having separately named functions?
No, you can’t normally do this. If you really insist on using the same name for two different functions, you can kind of fake it by returning a proxy object with overloaded conversion operators: