01x03 Simple Introduction to C + +

Source: Internet
Author: User

Here you will get a rough introduction to the C + + language. Although I like to see this kind of introduction, but I can understand the people who do not understand the heap of words to see a lot of the desire for violence ... So let me take care of the problem.

After all, for the pure novice, veteran please mouth mercy ... If you do not understand, look directly at the example of Bold.

C + + is a modified and enhanced version of the language, both of which have been popular in the world for more than 30 years, but are still very vibrant. C and C + + were born at Bell Labs. Some people say C + + is less efficient than C, he's wrong.

(The background is so little ... Next to the real ~)

C + + is a process-oriented and object-oriented programming language. Programming languages We all know what it is.

(not clear?) All right. programming language refers to a language similar to natural language used to communicate with computers , most of which are spelled in English letters.

Computers do not understand the ever-changing human language, so the need for human design a language specification, and then let the computer understand the language specification of each word represents what meaning (so C + + only need 80 or so words, too many humans also teach not computer). This language specification is called a programming language.

I really can't read the example above. in order to preserve a bit of mystery, here is not an example of C + +, choose a little bit of Ruby programming language. Now let's compare the example of using English and Ruby to make a computer say a word. (Suppose the computer can understand English)

English (Natural language)

Ruby (programming language)

  1. Print "Hello" on the screen.
  2. Print "Hello".
  3. Print "Hello" on the screens, be quick.

(meaning "Hello" is displayed on the screen anyway)

1. puts "Hello"

2. P "Hello"

3. Print "Hello"

It can be seen that English is very flexible. Ruby also looks like there are 3 statements that allow the computer to display "Hello", but the difference is that this is only 3 of Ruby's. You can't add a be quick in the back, can't add a name in front, quotation marks can not be omitted, puts can not be written put--this is all set dead, changed a little bit of computer will not recognize it.

Wouldn't it be difficult to program? not = =. Because the use of more than a few times, nature will not write anything wrong, after all, is very simple English.

As mentioned earlier, C + + is a process-oriented and OO programming language.

So what are process-oriented and object-oriented? These two terms look very wonderful, it is estimated that the translator's head was kicked by the donkey. Object-oriented is not easy to explain, but the first half of the visual content is not subject to object-oriented knowledge. Let's talk about the process first.

What is the process and how to understand it? In this way, the program is put into a pre-designed script, so that it will complete the work according to the designer's wishes.

that's a metaphor. Suppose you are a worker assembling a car, you need to assemble a car. Now give you all the parts and instructions for all the assembly steps. You assemble it according to the instructions of the instructions, follow the steps above, and obey the instructions.

At this point, you become a process-oriented program, and your task as a program is to assemble a car.

Let me give you an example. A simple process-oriented computational program can be written in the form of a manual. Let's say you become a calculator, and each person gives you 2 numbers, and you yell out two of them. If it is two 0, you turn off your computer:

1, listen, until you hear two numbers.

2. If two digits are not 0 and 0, continue. If it is 2 0, turn off your own machine.

3, roar out two numbers and

4, skip to the first step to continue.

This manual lets you do, is a very typical "process-oriented" thing. It has already covered all the elements of process-oriented: order, cycle, and judging conditions. Even if you do not understand, it doesn't matter, slowly tomorrow, you will understand =. =

C + + is case sensitive. This means that neither the C + + command nor the name you take will change its case. For example, C in C + + is a command (c + + can almost completely use C code), printf, you can not write printf, or printf. Fortunately, all of the commands in C + + are all lowercase, unlike Java, which can be worn out by switching the casing.

C + + In each statement to the end of a semicolon, in general, as long as no semicolon, even if you knock more returns, the system will not think this sentence is finished.

For example, the following code is a meaning:(take up Chinese expression)

Add 5 to the number of 猹 and subtract 3;

Put the number of 猹

Plus 5 minus 3;

Put the number of 猹

Plus

5

Minus 3;

But the following sentences are wrong:

Put 猹 's

Number

Plus 5 minus 3;

"The number of 猹" as a separate whole, is not to be separated by line break. as you can understand, there can be any length of time between each word in a statement, but one word cannot be divided into two halves.

C + +, like many programming languages, needs to be " compiled " before it can be run.

What is compilation? In fact, when you finish writing a code, the code is still in the human understanding of the stage, the computer still can not directly put this code into the CPU, let it run out.

At this point, you need a class of software to convert your code into a computer-recognized "10" string. So the computer finally recognize your code, so happy and happy, so you can run. Such behavior is called compiling , and such software is called a " compiler ". Most of the time, at least in the case of our encounter, the compilation is fully automatic, one-click completion.

If your code unfortunately where the missing a colon, write a wrong word or something, resulting in code syntax error, the compiler will compile at the same time as 猹 hit a tree jam, automatically stop compiling, and give the corresponding error information to help you correct.

C + + Simple introduction that's it, because it hasn't started yet, so it's just over. This section is mainly to let you first feel the programming atmosphere.

In fact, the programming is like writing the instructions in general, but to be written in a computer-recognized format. The next section will explain how to install the compiler--both PC and phone, tablet!

01x03 Simple Introduction to C + +

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.