| You can't use the assignment operator= to assign one string to another |
You can't use the assignment operator= to assign one
plain array to another.
For the language an array is an array, char or not. All arrays fail the same.
A constant C-string literal, like
"R2D2" is a shorthand for literal array
{ 'R', '2', 'D', '2', '\0' }.
| You could either overload the = operator |
No. Not for plain array. For user types, yes, but there is already "user type"
std::string.
| create a small quick function |
Recreate
strcpy() or other C-string handling functions from Standard C Library?
Reinventing a wheel is good for learning, but one should learn to use the existing wheels too.
Note that there is no "operator=" in the OP's code. The
= is not
that =.
What it is, is part of initialization syntax. Not an operator.