C++ Error: 'no match for ‘operator=’ (operand types are ‘expression::TObject’ and ‘<brace-enclosed initializer list>’)': Solution and Explanation
The error message 'no match for ‘operator=’ (operand types are ‘expression::TObject’ and ‘operator= for the types expression::TObject and <brace-enclosed initializer list>.
In the provided code snippet, you're attempting to assign a brace-enclosed initializer list to the envelop variable of type expression::TObject. The compiler cannot find a suitable assignment operator for this operation.
To resolve this error, you need to either define an assignment operator for the TObject class that can handle initialization with a brace-enclosed initializer list, or modify the code to assign values individually instead of using an initializer list.
Here's an example of modifying the code to assign values individually:
envelop.setType(TObjectType::NORMAL);
envelop.setName('envelop');
Ensure that the TObject class has appropriate member functions or constructors to set the type and name separately.
原文地址: https://www.cveoy.top/t/topic/o7eV 著作权归作者所有。请勿转载和采集!