I get the following error message:
conversion from ‘BaseClass’ to non-scalar type ‘DerivedClass’ requested
while compiling something like:
AnotherClass response;
DerivedClass message = response.serialize(QString("someStuff"));
where I have
BaseClass AnotherClass::serialize( const QString& valueName ) const
and
class DerivedClass : public BaseClass
{
...
DerivedClass &operator=(const BaseClass &other);
}
Can someone explain what is wrong here, and more importantly why?
DerivedClass message = response.serialize(QString("someStuff"));
This is copy-initialization, not assignment, and operator=
doesn't even come in play.
You either need a constructor that takes BaseClass
or write it like this:
AnotherClass response;
DerivedClass message;
message = response.serialize(QString("someStuff")); // assignment
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments