1.1 Write the first C ++ program

Introduction to C ++

C ++ is one of the most popular language computer applications, and is written in big-budget computer games most popular languages.

C ++ is a direct descendant of the C language, a superset of the C language, contain virtually all of its contents.

Moreover, C ++ also provides a better way to solve the problem and some of the new features.

IOS standard

Often referred to as ANSI (American National Standards Institute) standards or the ANSI / ISO standard. The most common is called to follow the ISO standard C ++ code is standard C ++.

Note

Is to the programmer, the compiler completely ignored.

// I is a comment
/ * Expand to multiple lines 
I also comment * /

Use whitespace characters - spaces, tabs, line breaks

The compiler ignores blank lines.

Blank lines are blocks may be divided together.

Used properly: Program clear and understandable

It contains additional files

Preprocessing instructions begin with '#'

#include<iostream>

Run the preprocessor before compiling, and text substitution based on various instructions.

Both ends of the file '<' and '>' tells the compiler to find the required files in its own file.

Definition of main () function

int main ()

Function is a set of program codes, it is possible to complete the task and returns a value. In the present embodiment, int denotes the function returns an integer value.

All function heads with a pair of parentheses after the function name.

All C ++ programs must have a function named main () as the starting point of the program. Program is run from here.

All functions are enclosed in curly braces. Inside the braces belonging to the function code is called a code block.

Function code blocks constitute the entire body of the function call.

Standard text output

std::cout << "Game Over!" << std::endl;

cout iostream object defined in the file, for transmitting data to the standard output stream.

Most programs, the standard output stream is just a computer items in the console window.

Output Operator << 

std is the namespace. It can be imagined as the area code phone number that uniquely identifies a group member belongs. :: is scope resolution operator.

Statement of termination

All statements must end with a semicolon, otherwise the compilation error.

From the main () function returns the value

Return 0 indicates that the program ended normally. The return value has nothing to do with the operating system.

Guess you like

Origin www.cnblogs.com/wlyperfect/p/12366964.html