Prefix ++ and suffix ++

Source: Internet
Author: User

I wrote the following code when I made an IP/PV statistics report. I haven't tried writing this code for a long time. I don't really remember how ++ uses prefixes or suffixes, but I remember when I was reading C ++ primer, it is said that C ++ programs should use prefixes, so this habit is retained.

I sent the following two pieces of code to a student on QQ and asked him if he could get 1 correct.

Section 1:

IntI = 0;

Map <string, integer> map =NewTreemap <string, integer> ();

Map. Put ("0", I );

IntOrgin = map. Get ("0 ");

Map. Put ("0", ++ orgin );

System.Out. Println (Map. Get ("0 "));

Section 2:

IntI = 0;

Map <string, integer> map =NewTreemap <string, integer> ();

Map. Put ("0", I );

IntOrgin = map. Get ("0 ");

Map. Put ("0", ++ orgin );

System.Out. Println (Map. Get ("0 "));

The student did not hesitate to say the first paragraph. After all, people are made of j2's, and every day they come into contact with these operators, which is not a fuel-saving Lamp.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.