struct opCall makes a nan
Bill Baxter
dnewsgroup at billbaxter.com
Sun Mar 23 17:08:14 PDT 2008
dominik wrote:
> I'm confused by this:
>
> struct vector3 {
>
> union {
> struct { float x, y, z; };
> struct { float r, g, b; };
> struct { float cell[3]; };
> };
>
> }
>
> struct plane {
>
> union {
> struct { vector3 N; float D; };
> struct { float cell[4]; };
> };
>
> plane opCall() {
> plane pl;
> N.x = 0.0f; N.y = 0.0f; N.z = 0.0f;
> D = 0.0f;
> return pl;
> };
Should be "static plane opCall".
> }
>
> and when I do this:
>
> plane plane_test;
> Stdout.formatln("{}", plane_test.N.x);
>
> it prints out a nan, when it should be 0F, ofcourse - what am I doing wrong?
Besides making the above a static opCall, you may also need to
explicitly call it.
auto plane = plane();
I don't think D calls it for you automatically.
--bb
More information about the Digitalmars-d-learn
mailing list