i++: Post increment can't be a lvalue because Post increment internally returns a temporary object (NOT the location of i) hence you cannot assign anything to it. The result of i++ can be used only as a rvalue. ++i: whereas, in Pre-increment value gets incremented and the same location is returned back to you, hence can be used as lvalue in an expression.(C++ allows this) Both can be used as rvalues though.
On 26 October 2012 18:54, rahul sharma <rahul23111...@gmail.com> wrote: > why pre inc. is l value and post is r value..please explain > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.