Hello. I'm trying to review operator overloading in C++, and I've run into a problem that involves both it and typecasting. This line of code is giving me issues:
Code:
Integer integer = "34";
The message is:
Code:
conversion from 'const char [3]' to non-scalar type 'Integer' requested|
At first this was coming up with the following operator overload:
Code:
Integer Integer::operator=(const string &str)
{
value = str;
return *this;
}
so I tried changing it to this to no avail:
Code:
Integer Integer::operator=(const char *str)
{
value = *str;
return *this;
}
What's the deal? There's almost definitely a simple fix to this, but I'm at a loss at the moment as to what it is. Thanks!