This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: error: no matching function for call to `Anton::Anton(Anton)`


Hi Eric,

As per section 5.5 of Stroustrup's C++PL (3rd ed or special ed), a temporary object cannot be bound to a non-const reference.

What you are trying to do is to bind a temporary object to a non-const reference.  That's not allowed by C++.

(For the reasons that it's not allowed, see C++PL.)

Change your pass-by-reference to a pass-by-value, then your program will compile.

Or make an explicit variable instead of using a temporary.
HTH,
--Eljay



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]