Topic
1 reply Latest Post - ‏2010-05-11T11:55:18Z by SystemAdmin
SystemAdmin
SystemAdmin
196 Posts
ACCEPTED ANSWER

Pinned topic Getting "1540-0218 (S) The call does not match any parameter list for "operator=" " error with xlC v8 on AIX 5.3

‏2010-05-11T11:22:51Z |

Hi,
I am getting the below error message when I try to compile the below code with xlC v8 on AIX 5.3.
"ex.C", line 23.4: 1540-0218 (S) The call does not match any parameter list for "operator=".
"ex.C", line 17.11: 1540-1283 (I) "P::operator=(P &)" is not a viable candidate.
"ex.C", line 23.6: 1540-0295 (I) A parameter of type "P &" cannot be initialized with an rvalue of type "P".
"ex.C", line 23.6: 1540-1290 (I) An rvalue cannot be converted to a reference to a non-const type.
#include<iostream>
using namespace std;
class P{
int data;
public:
P(int data){ }
P& operator=(P&);
void swishswish();
};
inline P& P::operator=(P&p){data=p.data; return *this;}
void P::swishswish(){data = 89; }
int main()
{
P iP(2);
iP = static_cast

(3);
iP.swishswish();
return 0;
}

Does anybody has any idea how to resolve this error?
Thanks,
Sharan



Updated on 2010-05-11T11:55:18Z at 2010-05-11T11:55:18Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    196 Posts
    ACCEPTED ANSWER

    Re: Getting "1540-0218 (S) The call does not match any parameter list for "operator=" " error with xlC v8 on AIX 5.3

    ‏2010-05-11T11:55:18Z  in response to SystemAdmin

    Use:
    P& operator=(P const &);
    You cannot bind temporaries to non-const references.