C++ manual tutorial

Read(52546) update time(2022-04-11)

C++ is a middle-level language that was designed and developed by Bjarne Stroustrup at Bell Labs in 1979. C++ further expands and improves the C language and is an object-oriented programming language. C++ runs on a variety of platforms, such as Windows, MAC operating systems, and various versions of UNIX. "C++ Tutorial" explains the C++ programming language in easy-to-understand terms.


C is the inheritance of C language. It can perform procedural programming of C language, object-based programming characterized by abstract data types, and oriented programming characterized by inheritance and polymorphism. Programming of objects. While C is good at object-oriented programming, it can also perform process-based programming. Therefore, C is big or small in terms of the size of the problem it can adapt to.

C not only has the practical features of efficient computer operation, but is also committed to improving the programming quality of large-scale programs and the problem description capabilities of programming languages.

Tips: C is the basis of C. C language and C language are compatible in many aspects. Therefore, after mastering C language, and then further learning C, you can learn object-oriented language with a familiar syntax, so as to achieve twice the result with half the effort.

C language programs are compiled because they need to be high-performance. But its development environment, in order to facilitate testing, makes the debugging environment interpretive. That is, during the development process, debugging is performed using an interpreted statement-by-statement execution method, and the final execution code of the program is generated using a compiled method that starts running without the development environment.

Let’s compile/execute the first C program!

The first C program

Instance

#include <iostream>
using namespace std;
int main()
{
    cout << "Hello, world!" << endl;
    return 0;
}

Run instance»

Click "Run instance" " button to view online examples

Tips: Our C language tutorial will help you learn the C programming language and its applications step by step. If you have any questions, please go to the PHP Chinese website C Language CommunityAsk your questions and enthusiastic netizens will answer them for you.

C language features

  • Support data encapsulation and data hiding

In C, classes support data Encapsulation tools and objects are the implementation of data encapsulation. C supports data encapsulation and data hiding by creating user-defined classes.

In object-oriented programming, data and functions that perform legal operations on the data are encapsulated together as a class definition. Objects are declared as variables of a given class. Each object of a given class contains a number of private members, public members and protected members specified by the class. Once a well-defined class is created, it can be viewed as a fully encapsulated entity that can be used as an integral unit. The actual inner workings of a class are hidden, and users of a well-defined class don't need to know how the class works, just how to use it.

  • Support inheritance and reuse

New types can be declared based on existing C classes. This is the idea of ​​inheritance and reuse. Through inheritance and reuse, you can organize the program structure more effectively, clarify the relationships between classes, and make full use of existing classes to complete more complex and in-depth development. The newly defined class is a subclass and becomes a derived class. It can inherit all non-private properties and methods from the parent class as its own members.

  • Support polymorphism

Use polymorphism to specify the behavior of each class. Polymorphism forms a tree structure consisting of parent classes and their subclasses. Each subclass in this tree can receive one or more messages with the same name. When a message is received by an object of a class in this tree, the object dynamically determines some usage of the message to be given to objects of subclasses. This feature of polymorphism allows for the use of high-level abstractions.

The combination of inheritance and polymorphism can easily generate a series of similar but unique objects. Due to inheritance, these objects share many similar characteristics. Due to polymorphism, one object can have a unique representation and another object have another representation.

C Technical Application

  • Scientific Computing

In the field of scientific computing, FORTRAN is one of the most used languages. However, C is also widely used in this field with its advantages such as advanced numerical calculation libraries and generic programming.

  • Network software

C has many mature libraries for network communication, the most representative of which are cross-platform, weight Level ACE library, this library can be said to be one of the most important achievements of the C language, and has applications in many important enterprises, departments and even the military.

  • operating system

In this field, C language is the main programming language used. But C, with its compatibility with C, the object-oriented nature is also beginning to have a place in this field.

Content covered by this C language tutorial manual

This tutorial covers all basic and advanced knowledge of C language, including C language syntax, types, variables, data structures, functions, and arrays , detailed introduction to scope, object-oriented and C resource library, etc.

Tips: Each chapter of this tutorial contains many C examples. You can directly click the "Run Example" button to view the results online. These examples will help you better understand and use the C language.

Latest chapter


C++ 有用的资源 2016-10-18
C++ 标准库 2016-10-18
C++ STL 教程 2016-10-18
C++ Web 编程 2016-10-18
C++ 多线程 2016-10-18
C++ 信号处理 2016-10-18
C++ 预处理器 2016-10-18
C++ 模板 2016-10-18