I am using the same qualifier for a union inside class and for a parameter to this class constructor, like this:
class A
{
union
{
C y;
D z;
}
x;
public:
A(B x);
}
I want to use y's constructor C(B q);
I attempted this:
A(B x)
: x.y(x)
{
}
But in this case it seems the compiler (or at least the IDE, in this case VS15) can't deal with name conflict smart, as it would if the case was simpler (ie. something like x(x)).
I had to resort to:
A(B x)
{
this->x.y = x;
}
When trying to use this pointer in initializer list, I get error "expected an identifier".
Is there any way to achieve the effect of this line in initialization list?