I have a structure:
typedef struct {
double x,y,z;
} XYZ;
I want to define a function like this:
double CalcDisparity(XYZ objposition,
XYZ eyeposition,
double InterOccularDistance = 65.0)
But I can't seem to find a way to assign a default value to eyeposition. How can I do this in C++?
It's
struct XYZ{
XYZ( double _x, double _y, double _z ) : x(_x), y(_y),z(_z){}
XYZ() : x(0.0), y(42.0), z(0.0){}
double x, y, z;
};
so that I now have a default constructor. Then you call it like this:
double CalcDisparity( XYZ objposition = XYZ(),
XYZ eyeposition = XYZ(),
double interOccularDistance = 65.0 )
But there's one small trick: you can't do a default value for the 1st and 3rd arguments only. One more thing: C is a language, C++ is another language.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With