C++primer (b)

Source: Internet
Author: User

1. The preprocessor is a statement that starts with # and represents a compilation instruction. Include causes the preprocessor to replace or add text before the program code is compiled.

2. Programs that use CIN and cout for input and output must contain file IStream. C++98 Standard:

#include <iostram>using namespace std;

The traditional 3.C language is that the header file uses the extension h as an easy way to identify the file type by name. C + + usage changed, C + + header file does not have extension, some C header files are converted to C + + header files, these files are renamed, the extension h is removed, and prefix C is prepended to the file name.

4.using compilation instructions. The namespace (namespace) is designed to make it easier for you to write large programs and to combine existing code from multiple vendors, and it helps to organize your programs. The following line of code

/* Lazy Practice */using namespace std;/* A better approach is to make only the required names available */using std::cout;using std::endl;using std::cin;

5. Control: Endl is a special C + + symbol that represents an important concept: re-starting a line. Inserting Endl in the output stream causes the screen cursor to move to the beginning of the next line. Special symbols such as Endl, which have special meanings for cout, are called control characters.

6. The line break "\ n" replaces the Endl to reduce the input amount. Endl ensure that the output is refreshed before the program continues to run (it is immediately displayed on the screen), and that using "\ n" does not provide such a guarantee.

7. An indivisible element in a line of code is called token. Typically, you must separate two marks with a space, tab, or carriage return, and spaces, tabs, and carriage returns are collectively known as white space.

Intelligent behavior of 8.cout-converts the corresponding type into a string based on the data type into the output stream and prints to the output device-object-oriented attributes (operator overloading) derived from C + +.

9. A class is a user-defined data type. To define a class, you need to describe what information it can represent and what operations can be performed on the data. Class to object is like type to variable.

10. The standard C library provides over 140 predefined functions.

11. Same as C (different from Pascal. C + + does not allow the function definition to be nested within another function definition.

The return value of the 12.main function is of type int, which can be thought of as a calling program for computer operating systems such as UNIX or Windows. Therefore, the return value of main () is not returned to other parts of the program, but is returned to the operating system. A return value of 0 means that the program runs successfully and nonzero means there is a problem. Therefore, if a C + + program cannot open the file, it can be designed to return a non-0 value. Then design a shell script or batch file to run the program. If the program issues a message that indicates a failure, take additional action.

13. In summary, there are several ways to allow programs to access the namespace STD, the following are 4 of them: 1. Use namespace Std; before the function definition, let all the functions in the file have all the elements in the namespace Std. 2. Place the using namespace STD in a specific function definition so that the function can use all the elements in the namespace Std. 3. Use a similar using std::cout in a specific function, such as a compile instruction, rather than using namespace STD, to allow the function to use the specified element, such as cout. 4. Use of the compile instruction is not used at all, and the prefix STD is used when the element in the namespace STD is required:: As shown below:std::cout<< "I ' m using cout and Endl from the Std namespace." <<std::endl;

14. The personal naming style is also noteworthy-it helps to maintain consistency and accuracy.

15. Fahrenheit temperature =1.8* Celsius temperature +32.0

C++primer (b)

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.