Hello, I am supposed to make a program in which I will be using Struct variables in Union. However, when I use Union, it shows me the error that its default constructor cannot be referenced.
I tried searching the issue on internet but I couldn't find a good solution. At one place, it was written that this is some compiler bug and it will be fixed with the update of Visual Studio 2015. However, I am using Visual Studio 2017 Enterprise and I am still facing this issue..
Can anyone help me resolve the issue, please?
Here is the code of my program.
A union may not contain anything that does not have a trivial copy constructor. You could think of this as meaning anything that cannot simply be copied byte-for-byte.
A std::string does not have a trivial copy constructor, so you're not allowed one in a union.