Mactavish <mdtabisha...@gmail.com> writes: > I have compiled this code in MS Visual C++ Express 2008 and it works as > it should be but when i compile this code in Mingw as a part of GCC ver > 4.4.1-2 the input() function should return a temporary object to 'ob' > object and invoke the assignment operator '=' but it doesn't and it > shows me error :"no match for 'operator=' in 'ob=input()()' "
This is the wrong mailing list for this question (the list is for gcc development). A better list would be <gcc-h...@gcc.gnu.org> or maybe the comp.lang.c++ newsgroup. As to your problem, I think it's a bug in your program (and a bug in VC++ that it accepts it). Later versions of gcc give a more explanatory error message, which make the reason more obvious: $ g++-4.6 -c s.cc s.cc: In function ‘int main()’: s.cc:63:14: error: no match for ‘operator=’ in ‘ob = input()()’ s.cc:63:14: note: candidate is: s.cc:46:8: note: sample sample::operator=(sample&) s.cc:46:8: note: no known conversion for argument 1 from ‘sample’ to ‘sample& {aka sample&}’ Temporary objects can't be passed as non-const references. You can fix it by changing the argument type of sample::operator= to be "const sample &" instead of "sample &". -Miles -- One of the lessons of history is that nothing is often a good thing to do, and always a clever thing to say. -- Will Durant