When initializing an object at definition, it’s not using assignment even when the
= syntax is used.
When you do:
Hero zak = foo;
it’s equivalent to:
Which is copy-initialization and as such invokes the copy-constructor.
The problem with
Hero bar = "HelloWorld";
is that it’s equivalent to:
Hero bar = Hero("HelloWorld");
which in turn is equivalent to:
And since you don’t have a constructor for
Hero("HelloWorld") it’s invalid.
CLICK HERE to find out more related problems solutions.