struct anonymous untagged union error attempting to reference a deleted function

  anonymous, c++, union

Recently, I try to convert my VS2008 c++ project to VS2019, because need to update libray, support etc, I have snippet, compiled on VS2008 but not with vs2019

struct A
{
  WORD insideA;
  A(): insideA(0)
  {}

  ~A(){}

}

struct B
{
  WORD insideB;
  B():insideB(0)
  {}

  ~B(){}
}

struct AB
{
  union
  {
    struct { A dataA; };
    struct 
    {
      WORD wX;
      B dataB;
    } 
  }
  
  AB()
    :wX(0)
  {}

}

struct USAGE
{
    AB usageAB;
    USAGE(AB &parAB)
      : usageAB(parAB) //<< attempting to reference a deleted function
    {}
}

Is there any standard changes with anonymous union between vs2008 and vs2019?

Source: Windows Questions C++

LEAVE A COMMENT