"Studious C + + 2nd Edition", chapter 1th, the first C + + program

Source: Internet
Author: User

Features and benefits of the program:

There is no ambiguity in the program language, the conversion to machine code will not have any problem of uncertainty;

can be executed repeatedly;

The speed of computer execution is very fast;

Terms:

Applications: User perspective, compile and post-test programs

Code: Programmer's view of the program, in addition to the data (for the program to process the passive information, the value and the word as the most basic), indicating the completion of the program part of the operation

Source code: Programs written in high-level languages

statement (; end) and compound statement

Machine code: The computer's native language, each computer instruction is composed of 0 and 1, usually in hexadecimal notation, for example, A7 C3 9E 58. Writing programs with machine code requires an in-depth understanding of the CPU architecture.

Compiler: A language translator that translates the source code into a machine code that the CPU can understand

C's Advantages and characteristics:

Refined, concise and comprehensive grammar, written to short, less than other programming language restrictions.

C + +:

Increased object-oriented programming capabilities for solving complex problems.

Classes and objects:

(it) classes are extended data structures that show how such objects are initialized, how they are used, and objects are instances of class definitions that really work.

To write a program:

A text editor such as MS Word or Notepad, but must be saved in plain text format.

IDE For example vs (for big projects, so it's not friendly for simple beginners).

Engineering: The entire document constituting a program. Vs:file->new->console application-> named->ok. File->new equivalent to new project

#include "stdafx.h" vs is required to create a console application (not a Windows application).

System ("PAUSE"); The window does not flash on the screen. Not MS-DOS or WINS, may not be valid.

Build: Compile + link,. cpp through the compiler into. obj. Compilation will find syntax errors and program structure errors. Vs:f7

Run: Find program logic error. Vs:ctrl+f5 ("Press any key to continue" is displayed to prevent the window from flashing on the screen).

cout object, left flow operator (<<)

C + + statements end with a semicolon, except for a few exceptions (? )

#include: Preprocessing directives (live to compiler)

C language and its standard library is separate (can not use the standard library and its own runtime), the library function of the standard library and the library object and user-defined non-essential differences, and therefore also need to declare and reuse. Header file to do this job.

<file>: Introduction of related declarations and definitions in C + + libraries. <iostream> is a precompiled-format virtual header file, so no. h.

""

#include <iostream> after two uses: (IT:STD is an object, it is imported, using it can directly use its data and functions,

Otherwise be used indirectly)

using namespace Std;

cout << "Whats up" << endl;

Or:

Std::cout << "Awesome" <<std::endl; Endl is a pre-defined constant in STD

Main function return value: returned to the operating system or development environment, General 0 for execution success.

Variable: The place where the data is stored. int var; Cin << var;

# # # #规则: C + + variables must be defined before they are used//basic a number of low-level errors that are not strictly caused

Three basic data formats: integer (int), floating-point number (double,8 bytes (PC all have 8-byte coprocessor), C + + operation to double, store default double unless specified for example 12.6F), text string (that is, string).

The C + + library internal variables begin with an underscore, so it is best to name the self-made variable without an underscore.

  

  

  

"Studious C + + 2nd Edition", chapter 1th, the first C + + program

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.