The code in question:
struct PCArea {
PCArea(
int minxx = 0,
int minyy = 0,
int maxxx = 0,
int maxyy = 0
) {}
};
struct NDCVolume {
NDCVolume() {}
operator PCArea() const;
};
// how does this operator work? how to use/read it?
NDCVolume ::operator PCArea() const {
return PCArea(iminx, iminy, imaxx, imaxy);
}
Redundant code has been removed from the snippet. I have used Visual Studio > Find All References but cannot spot any where it is being used. To me, it looks like a member method without a specified return value.
How is this different from below?
PCArea NDCVolume::PCArea() const;
It’s a conversion operator.
In case of
NDCVolume NDCVolume::PCArea() const;it’s just a function and will not be used implicitin case of conversion operator defined you can write
in the second case (with regular function) you will have to make it explicit: