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: Const in default function arguments?


Hi Eric,

>Why won't the non-const version compile?

Because by making it a non-const reference, you are saying that you are
going to modify it.  That is to say, you are making an "OUT" or "UPDATE"
(in/out) parameter.

When you specify a default object, you are making a temporary.

It doesn't make sense to modify a temporary.

--Eljay


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