I have a function that overloads operator=
in class 'ssm'
ssm& operator=(ssm& rhs);
Later I use an ssm object (itsSSM) as a member of another class(mt3dset). I use the following declaration to initialize that member in the constructor.
itsSSM= ssm();
But I am getting an error:
error: no match for ‘operator=’ in ‘((mt3dSet*)this)->mt3dSet::itsSSM = ssm()’
error: no known conversion for argument 1 from ‘ssm’ to ‘ssm&’
Is it a problem with compiler (g++ 4.7)? (Please ask for more information if required)
Nope, it's not a problem with the compiler. You can't bind a temporary to a non-const reference. Note that Visual C++ has an extension to allow this non-standard feature.
Just change your copy assignent to take its argument as const:
ssm& operator=(const ssm& rhs);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With