I've been asked this question in a job interview, and even after compiling it, I still don't understand the outcome...
I have the following class:
class Point
{
public:
Point(double x = 0, double y = 0) { m_X = x; m_Y = y; }
double m_X, m_Y;
};
and main.cpp is:
int main()
{
double a = 1, r = 1, xCoord = 5, yCoord = 7;
Point p = (a+r*xCoord , a+r*yCoord);
cout<<"X = "<<p.m_X<<" Y = "<<p.m_Y<<endl;
return 0;
}
The data members of class p are getting the values:
m_X = a+r*yCoord, m_Y = 0
Now, why is that?