C + + Pay attention to easy error points

Source: Internet
Author: User

1.cout using Endl,cin without Endl

1 cin>>a>>2 cout<<a<<b<<endl;


2. Do not add a semicolon after the definition of the function, it is finished.

1 int A (int  b)2{3   // processing statement 4   return(); 5 }


The input of the string in 3.c++ is used char[] and strcpy (A, "...") and the header file stdio.h;

1 Char a[]; 2 strcpy (A,"    " )


4.c++ output white space with << "" to output, unlike the C language

1 cout<<"a="<<"    <<Endl; 2 printf ("a=%d", a);


5. Variable names cannot be the same as function names
6. Integer and floating-point type cannot be mixed together to calculate, error
7. Do not forget to add return 0 at the end of the main function;

8. There is no semicolon after the definition name of the class, there is a semicolon after the definition, there is no semicolon after the function definition name, and no semicolon is defined.

1 class class name 2 {3     Public : 4    // Public Part 5    Private : 6   // Private Part 7 };

C + + Pay attention to easy error points

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.