J
Jess
Hello,
I learned that if we do "v.end()", then the returned iterator is a
temporary object and hence cannot be changed like
--v.end();
Why is the returned iterator a temporary pointer? I think when the
result of a function is returned, then a non-temporary object is
created, with value copied from the local temporary object. If the
code above still gets us a temporary object, then I think the non-temp-
object-creation hasn't taken place yet. Does it only happen if we do
p = v.end();
ie. assign v.end() to some variable?
It is also said that we can't modify it because it has a built in
type. I guess "build-in" means pointer type here. This sounds to me
as if we could modify the temporary object if it is of class type.
I'm quite confused....
Thanks,
Jess
I learned that if we do "v.end()", then the returned iterator is a
temporary object and hence cannot be changed like
--v.end();
Why is the returned iterator a temporary pointer? I think when the
result of a function is returned, then a non-temporary object is
created, with value copied from the local temporary object. If the
code above still gets us a temporary object, then I think the non-temp-
object-creation hasn't taken place yet. Does it only happen if we do
p = v.end();
ie. assign v.end() to some variable?
It is also said that we can't modify it because it has a built in
type. I guess "build-in" means pointer type here. This sounds to me
as if we could modify the temporary object if it is of class type.
I'm quite confused....
Thanks,
Jess