c++--Study Notes 002

Source: Internet
Author: User

20150426

Const type Descriptor

const int A;

int const A;

The above is exactly the same, describing a const integer variable

Read more and write well is the only way of C + +

To master learning is the only way to become a master, learning the source code of excellent open source products, learning the design ideas, programming style.

The purpose of the multi-reading is only to learn the knowledge and experience of others, and the purpose is to translate the knowledge and experience of others only and experience into their own.

CL/EHSC Hellowlrd.cpp

"#include"

Directive is used to embed the specified file in the location of the directive before compiling as part of the entire source program.

You can use the features defined by the file. The functionality of the C + + standard library is typically called in this way.

Typically use "" to embed files in the current project directory

Use <> to embed library files in various project inclusion directories.

In C + +, each statement is terminated with a semicolon;

STD is a namespace, and Cout,endl is an identifier under the Std namespace

is a single-line comment,//followed by a comment until all the contents of the newline are included

/* * * This is a pair appearance, is a note

Comments have a preamble and explanatory comments

The position of the note can be placed above or to the right of the code, not below.

The compiler's job is to translate the high-level language C + + into a low-level language (machine Language) object code, machines code

The purpose of the linker is to link one or more target files and library functions generated by compiler compilation into an executable file.

Visual Studio integrated compilers are cl.exe

See Figure 2-6

CL/C/EHSC Helloworld.cpp

CL is the instruction that compiles the source file, and subsequent arguments are used to specify the behavior of the compiler.

/C means compile-only not linked

/EHsc specifying what exception handling model the compiler uses

C + + programs typically have multiple source files that are compiled to form multiple target files that need to be finally assembled into an executable program.

The process of assembling and replacing a target file is a link, that is, the work of a linker.

Linker is Link.exe

You can use the following command to let the linker link to the target file helloworld.obj, to get the executable Helloworld.exe file

Link Helloworld.obj

Figure 2-8 The purpose of my life

The life purpose of a C + + program is to describe the data and process the data

Basic input/output stream (iostream)

IStream input diplomat

Ostream Export diplomat

Iostream class Library is a member of standard class library

Endl is a manipulated character

IStream is the input stream

Ostream is the output stream

The process of displaying data from the program to the screen or writing it to a file, which flows from the program to the outside, is output, and the process of data flowing from the outside to the program is input.

A C + + program that flows data from one object to another is called a stream.

The format of the output needs to be controlled

\ n = line break

\ t indicates the distance between one tab

Ofstream and Ifstream are the two classes that have the <fstream> header file defined, respectively, responsible for the output and input of the data.

The difference with cout,cin is that fin,fout in FStream can associate an object with a specific file by opening the file itself. Use the caret << and >> to manipulate these objects.

Integrated development Environment integrated development environment, IDE

Yes:

Visual Studio

Eclipse CDT

Turbo C + +

C + + Builder

Dev-c++

Visual C + + (VC or MSVC) is an important part of development suite Visual Studio

After some menu items, there is an ellipsis, which means that clicking the menu item regrets that a dialog box pops up, allowing the user to do further work.

20150427

Debug version and Release version

The DEBGU version is a debug version,

Release is an optimized version that is sent to the user

VSS Source Code Control tool. You can make security changes to your existing code. Each time you modify the code, you need to check out the code from the server to local, and after the modification is complete, the code is checked in locally to the server.

Each check-in check-out leaves the appropriate timestamp on the server

A program uses data to describe the real world.

In the programming language, these same types of data are abstracted into data structures.

A data structure is a description of a class of information in the real world.

An int is used to describe an integer in a range.

Use char to describe all the characters.

The data type is like the surnames of the C + + world, a data type that determines who the data is.

Data types are also classified into basic data types and constructed data types.

The base data type is the lowest-level populace in C + + and cannot be divided, such as an integer one character.

A variety of data types---correspond to---a variety of real-world things.

The construction data type consists of a basic data type or another constructed data type.

There are four types of construction data:

array type; struct type; Union type; enumeration type.

Variables and constants

The value of the variable can be read or modified

The value of a constant can only be read and cannot be modified

In a program, constants can be used directly, and variables must be declared before they are used.

If there are integer variables, integer constants, floating-point constants, floating-point variables.

declaring variable = variable declaration

A variable declaration consists of two parts, the data type and the variable name.

The data type is a description of the variable type.

An illegal variable declaration,

You cannot use a keyword as a variable name, such as int case

Variable names cannot start with a number

Variable names cannot have spaces

There is at least one space interval between the data type descriptor and the variable name

A variable declaration must be placed before the variable is used, usually at the beginning of the body of the function.

Naming methods for variable names: Hungarian nomenclature

Variable name = attribute + Type + Object description

Variable names are best used in English words or combinations

Single-character variable name i,j,k is usually used to make a local variable of a function.

A variable is a food in the real world, the seven Essence is an entity, so the name of the variable should use "noun" or "adjective + noun"

float Fvalue; Noun

float foldvalue;//adjective + noun

Avoid numeric numbering in names

Constants are all uppercase letters, and the words are split with underscores.

Using a well-appointed prefix,

For example, S_ represents a static variable

G_ represents a global variable

M_ represents a data member of a class

If the variable is not initialized, the system will automatically give a random value, and use this random value to operate, may cause the program to run the result error. Even cause the program to crash.

20150428

declaring variables

int nstudentnum; declaring variables

nstudentnum=1000; Assigning an initial value

The above can also be the case

int nstudentnum=1000;

Constants can be numeric, character, String, and so on.

Usually used to assign a variable or use it directly.

Assign a value to a variable with a constant

Strname= "Chenliangqiao"

Calculate directly using constants

farea=fr*fr*3.1415926

The "Chenliangqiao" and "3.1415926" here are two constants.

When the assignment operation and multiplication are complete, the two constants are meaningless.

C + + constants mainly include integral type constants, floating-point constants, character constants, string constants.

Integer constants are integers that appear in literal form, most commonly decimal, octal, hexadecimal

Decimal example: 0, 123,-1

Octal example: An integer starting with 0 is an octal number, 0123, 022

Hexadecimal example: The number starting at 0x or 0X is the hexadecimal number, 0x123, -0x2

nheight=173;//Decimal constant

nheight=0255;//Eight binary constants

Nheight=0xad;//16 binary constants

Floating-point constants

is a floating-point number in the form of text, with two, fractional, and exponential forms.

Decimal forms have numbers and decimal points, such as 1.0, 0.1,. 123, 0.0

Index

In exponential form, 1.1e5 indicates that the 1.1*10 5-Time Square

0.123E-4 indicates a negative 4-time 0.123*10

Character constants

A single quote box, which is a single character used in the program.

such as "A", "a", "! “

Assign a value to a variable with a character constant

Char amark= ' A '

Output a character constant '! ', display to screen

cout<< '! ' <<endl;


c++--Study Notes 002

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.