Is the C ++ programming language so suitable?

Source: Internet
Author: User

In fact, the C # syntax is very similar to C ++, and some changes cause serious errors. This article will give a detailed analysis and introduction to the C ++ programming language that most users encounter headaches, however, has the C ++ environment actually improved in recent years?

Lexical rules of C ++ programming languages

1,C ++Character Set of Programming Language

Characters are the smallest symbols that can be distinguished. The C ++ character set consists of uppercase and lowercase English letters (a-z and A-Z), data characters (0-9), special characters (spaces ,!, #, %, ^, &, *, _, <,> ,?, .

2. Word and lexical rules

A word is also called a lexical mark. It is a minimum lexical unit that consists of several characters. C ++ has 6 types of words: identifiers, keywords, operators, delimiters, constants, and annotators. Pay special attention to the lexical rules of these words during encoding.

Note the following blank characters in C ++:C ++A blank character is often used in programming languages. In fact, a blank character is not a single character. It is a general term for space characters, line breaks, and horizontal tabs. Note that a blank space character is not equal to a space character, but contains a space character.

There is also an empty character, which should be separated from a blank character. A null character is the character whose ASCII value is 0. A null character has a special purpose in C ++. It is used as the string Terminator. The string constants stored in the memory all have an terminator at the end, that is, an empty character, which is expressed as '\ 0' by the escape sequence method '.

Basic components of C ++ program structure

1. Pre-processing commands. C ++ provides three types of pre-processing commands: macro-defined commands, file inclusion commands, and Conditional compilation commands.

2. Input and Output statements are always indispensable in the C ++ program to implement information exchange with the program. In particular, the screen output function is used by almost every program to display computer results on the screen.

3. The C ++ program is composed of several files, and each file is composed of several functions. Therefore, it can be considered that the C ++ program is a function string, it is composed of several functions, which are opposite to each other and are parallel, and can be called between functions. There must be a main () in several letters that comprise a program ().

4. A statement is the basic unit of a program. A function is composed of several statements. However, empty functions do not have statements. A statement is composed of words separated by space characters. Statements in the C ++ program end with a semicolon. In addition to expression statements and empty statements, statements include composite statements, branch statements, cyclic statements, and steering statements.

5 variables. Most programs need to describe and use variables. In a broad sense, an object contains a variable, which is also called an object. In a narrow sense, an object is regarded as an instance of a class, and an object is an object of a class.

6 others. In addition to the five parts described above, there are other components. For example, symbolic constants and comments are also part of the program. In C ++, we try to define constants as symbolic constants. In C ++ programs, symbolic constants appear. These symbolic constants represent a specific constant value.

  • How to program the Visual C ++ Interface
  • Analysis of the C ++ Development Environment
  • Differences in performance between different C ++ Compilers
  • How to compile the C ++ Environment
  • How can we develop VC ++ exactly?

C ++ program writing format

Pay attention to programmingC ++The basic principle for writing a programming language is to write a statement in a row. You can write multiple phrase sentences in one row. A long statement can write multiple rows in one row. The branch principle is that one word cannot be separated. It is best not to separate a string referenced in double quotation marks. If it must be separated, some compilation systems require the addition of a line break ("\") at the end of the line.

Implementation of C ++ Program

The implementation of C ++ source programs is the same as that of other advanced language source programs. Generally, it must be edited, compiled, and run. The most important part is the compilation process. C ++ is an advanced language that is compiled. The implementation of the C ++ program must use a certainC ++The compiler of the programming language compiles the program.

The function of the compiler is to convert the source code of a program into the form of machine code, called the target code. Then, connect the target code to generate an executable file. This process can be divided into three sub-processes: preprocessing process, compilation process (lexical analysis, syntax analysis, symbol table, error processing program, and target code generation), and connection process.

First, repeat Bjarne's statement: "Our system is already extremely complex. To avoid the complexity of C ++, we simply don't need the C ++ Linus approach ." In all areas where C and C ++ are available, C ++ is a better language than C. When I say "better", what I say isC ++Programming Languages have more secure type checks, better abstraction mechanisms, and better libraries than C.

Of course, there are exceptions in everything. If project 1 you are working on is not large. 2) No abstract mechanism is used in encoding, or even ADT abstract data types, such as std: complex, which does not contain Polymorphism or inheritance), and RAII does not, the exception is also unavailable. 3) You don't need to connect to the basic library, such as smart pointers and containers that simplify resource management.

Maybe you can use C. If you do, you don't have to argue with me because I can't refute you. The fields we are talking about here are roughly the areas listed by Bjarne in the "C ++ Application List. The bottom line is: Remove unnecessary complexity from C ++, leave essential and important language features, simplify the language model, and eliminate historical burdens.

Even the opponents of C ++ may have difficulty finding a reason to say "I still don't need C ++ ". In my opinion, there is only one reason for rational opposition to C ++ in a practical sense: the confusions brought by the complexity of C ++ offset or even exceed the benefits of the abstract mechanism and library of C ++ in his specific project.

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.