GCC is right. A myA(7);
is direct initialisation - it initialises myA
using the constructor taking an int
parameter.
A myA = 7;
is copy initialisation - it initialises a temporary A
object using the int
constructor, and then initialises myA
from this temporary using a copy constructor. Even though the copy will most likely be elided in practice, it must still be legal. And sinec the copy constructor is not accessible, it fails.
To make A myA = 7;
work, you'll have to make the copy (or move) constructor accessible - which basically means making it public.