C++primer (1) Quick Start

Source: Internet
Author: User

First, Quick Start

//main a function is the only function that is explicitly called by the operating system.

Standard Access: Cin

Standard output: cout

The left operand of the input (") output (") operator is IO stream object, the right operand is the value to output, and the output operation is to write the right operand to the left operand as the ostream , and the input operation is to accept IStream object as the left operand, accepting an object as the right operand, from the IStream The operand reads the data and saves it to the right operand.

The result of the input-output expression is the value of the left-hand operand, which means that the input-output operation returns the output input stream itself. That is why the output input request sequence can be combined into a single statement.

// will be "..." the content is written to cout object in

  std::cout<< "Enter numbers:" << Std::endl;


// from IStream operands are read into the data and saved in the right operand

  Std::cin>> v1 >> v2;

//endl with: 1 , output line wrapping 2 , refreshes the function of the buffer associated with the device

  std::cout<< "The sum of" << v1 << "and" << v2

    << "is" << v1 + v2 << Std::endl;

//iostream The library definition accepts the input and output operator versions of all built-in types, so there is no need to worry about type issues.

C + + The space symbol where most of the program appears can be replaced by a newline character, with the only exception being the whitespace in string literals. Whitespace is not allowed in preprocessing directives.

Control structure:

While (condition) { while_body_statement } condition is True while execution is not performed for false.

and the For ( an expression;condition; expression ) {}

if (condition)

when we use IStream object as a condition, and the result is the state of the test flow. If the stream is valid (that is, if it is possible to read into the next input) then the test succeeds. theIStream object is invalid when a file terminator is encountered or an invalid input is encountered.

file end symbol, window Next is control+z and Unix include Macos-x , usually with Control+d .

A class is an organization that can be used to define its own data structures, similar to variable definitions, using classes to define variables, with a special salutation: objects

For objects, you can use addition, input and output, and assignment operations. The summation of an integer is the result of the traditional summation, and the sum of the objects is the result of the addition of two object components (or attributes).

There is a member function in the object component, or it can be called a class method.

member functions are defined only once, but are treated as members of each object.

through the . " to access a member the left operator must be a class type, and the right operator must specify a member of that type.

C++primer (1) Quick Start

Related Article

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.