H
Ham Pastrami
class Point {
public:
const int x, y;
Point(int x, int y);
}
Point:oint(int x, int y) : x(x), y(y)
{
}
This compiles with MSVC and the data seems correct at runtime, but is this
code safe or is it compiler-dependent? It seems ambiguous that the
initializer list is using member_x and arg_x at the same time. More
specifically, what should happen when
Point:oint(int x, int y) : x(x+1), y(x+y)
the initializer for y could be reasonably interpreted as either (member_x+y)
or (arg_x+y)?
public:
const int x, y;
Point(int x, int y);
}
Point:oint(int x, int y) : x(x), y(y)
{
}
This compiles with MSVC and the data seems correct at runtime, but is this
code safe or is it compiler-dependent? It seems ambiguous that the
initializer list is using member_x and arg_x at the same time. More
specifically, what should happen when
Point:oint(int x, int y) : x(x+1), y(x+y)
the initializer for y could be reasonably interpreted as either (member_x+y)
or (arg_x+y)?