I have this code in a new C ++ editor that I am testing (CLion):
struct screenPoint {
float x = 0, y = 0;
screenPoint(float x_, float y_): x{x_}, y{y_}{}
};
struct position {
screenPoint ul;
float width = 0, height = 0;
position(screenPoint p, float w, float h): ul{p},width{w},height{h}{}
};
Near the end there is an initialization operator ul{p}, which I thought was a valid C ++ way to use parenthesis initialization. However, CLion complains:
Incompatible types in initialiser: Types 'float' and 'screenPoint' are not compatible.
Note. There are no errors or warnings from the compiler, and the code is working properly.
If I change it to ul(p), the error will disappear.
Now I know that I do screenPointnot have a constructor that accepts another screenPoint, but this is necessary for initialization as follows:
source
share