ok, so I just started working with classes when I came across something I'm not sure how to interpreter.

I was doing an exercise that asked to build a class to store 3d coordinates and an outside fuction to compute the dot product (and some vague allusion to pass-by-ref that I'm not sure I got right).

so I build the class:
Code:
class point
{
    double x,y,z;
    public:
    void set(double a, double b, double c)
        {x=a; y=b; z=c;}
    double* xref() {return &x;}
    double* yref() {return &y;}
    double* zref() {return &z;}
};
and then start noticing something strange when I'm working on the function... a few tests later I come up with this:
Code:
double dot_product(double *v1, double *v2)
   {return v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2];}
(to which I'm feeding the ONLY ".xref()" results.)

I've recompiled this a few times and this always work....

so my question is: Is it built into the language that the variables in a class are stored in adjacent memory blocks? or my compiler just decided to do so and therefore I can't rely on it to do so in the future?