Cplusplus 简明教程

C++ Tutorial

本 C 教程由经验丰富的 C 程序员编写,它帮助初学者直到高级程序员使用简单且便捷的步骤学习 C。本教程使用简单实用的方法为软件工程师描述 C 的概念。

This C tutorial has been written by experienced C programmers which helps beginners to advanced programmers while learning C in simple and easy step. This tutorial uses a simple and practical approach to describe the concepts of C to software engineers.

What is C++?

C 是 Bjarne Stroustrup 从 1979 年开始在贝尔实验室开发的一种中等编程语言。 C 可在多种平台上运行,例如 Windows、Mac OS 和各种版本的 UNIX。C 是 C programming language 的扩展,带有面向对象的编程理念。或者,我们可以说“C 是包含对象面向概念附加实现的 C 编程超集”。

C is a middle-level programming language developed by Bjarne Stroustrup starting in 1979 at Bell Labs. C runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX. C is an extension of C programming language with object-oriented programming concepts. Or, we can say "C is a super set of C programming with additional implementation of object-oriented concepts".

Why to Learn C++

C 是学生与从业人员成为优秀软件开发者的重要编程语言。我将列出学习 C 的一些主要优点:

C is an important programming language for the students and working professionals to become a great Software Developer. I will list down some of the key advantages of learning C:

  1. C++ is very close to hardware, so you get a chance to work at a low level which gives you lot of control in terms of memory management, better performance and finally a robust software development.

  2. C++ programming gives you a clear understanding about Object Oriented Programming. You will understand low level implementation of polymorphism when you will implement virtual tables and virtual table pointers, or dynamic type identification.

  3. C is one of the every green programming languages and loved by millions of software developers. If you are a great C programmer then you will never sit without work and more importantly you will get highly paid for your work.

  4. C++ is the most widely used programming languages in application and system programming. So you can choose your area of interest of software development.

  5. C++ really teaches you the difference between compiler, linker and loader, different data types, storage classes, variable types their scopes etc.

学习 C 编程有 1000 多个充分的理由。但有一件事可以肯定的是,要学习任何编程语言(不仅仅是 C),您只需要不断编码,最终您将成为该语言的专家。

There are 1000s of good reasons to learn C Programming. But one thing for sure, to learn any programming language, not only C, you just need to code, and code and finally code until you become expert.

Hello, World! Program Using C++

为了让您对 C programming 产生一点兴趣,我将给您一个传统的 C Hello World 程序,您可以通过点击“编辑和运行”来尝试它。

Just to give you a little excitement about C programming, I’m going to give you a small conventional C Hello World program, You can try it by clicking on "Edit & Run".

以下是将“Hello World”打印到屏幕上的代码 −

Below is the code to print "Hello World" on the screen −

#include <iostream>
using namespace std;

// main() is where program execution begins.
int main() {
   cout << "Hello, World!"; // prints Hello, World!
   return 0;
}

C++ Online Compiler

我们提供了一个简单、用户友好且快速的 C 在线编译器,您可以在其中编写、保存、运行和分享您的 C 程序。单击此链接以打开它: C++ Online Compiler

We provided an easy, user-friendly, and fast C online compiler, where you can write, save, run, and share your C programs. Click on this link to open it: C++ Online Compiler.

尝试点击图标,使用 C 编程来打印传统的“你好,世界!”来运行以下 C 代码。

Try to click the icon to run the following C code to print conventional "Hello, World!" using C Programming.

#include <iostream>
using namespace std;

int main() {
   cout << "Hello, World!"; // prints Hello, World!
   return 0;
}

有许多可用的 C++ 编译器,你可以用它们来编译和运行以上提到的程序:

There are many C++ compilers available which you can use to compile and run above mentioned program:

  1. Apple C++. Xcode

  2. Bloodshed Dev-C++

  3. Clang C++

  4. Cygwin (GNU C++)

  5. Mentor Graphics

  6. MINGW - "Minimalist GNU for Windows"

  7. GNU CC source

  8. IBM C++

  9. Intel C++

  10. Microsoft Visual C++

  11. Oracle C++

  12. HP C++

Features of C++

以下为 C++ 编程语言的功能——

The following are the features of C++ programming language −

  1. C language compatibility: C++ provides backward compatibility with C, it supports all features of C language.

  2. Object-oriented programming: C++ supports the concepts of OOPs such as objects & classes, encapsulation, data binding, inheritance, and polymorphism.

  3. *Compiled language: *C++ is a compiler language where the complete code is converted into machine language, which makes it a faster programming language.

  4. *Standard template library: *C++ provides many data structures and algorithms-related library collections, such as template libraries for contains, iterators, algorithms, etc.

  5. Dynamic memory management: C++ provides two operators new and delete that help to allocate and deallocate memory blocks dynamically.

  6. Exceptional handling: C++ provides try, catch, and throw blocks for exceptional handling, which were not available in C programming.

Applications of C++ Programming

如前所述,C++ 是最广泛使用的编程语言之一。它几乎存在于软件开发的每个领域中。我将在下面列出其中的几个:

As mentioned before, C++ is one of the most widely used programming languages. It has it’s presence in almost every area of software development. I’m going to list few of them here:

  1. Application Software Development - C programming has been used in developing almost all the major Operating Systems like Windows, Mac OSX and Linux. Apart from the operating systems, the core part of many browsers like Mozilla Firefox and Chrome have been written using C. C++ also has been used in developing the most popular database system called MySQL.

  2. Programming Languages Development - C++ has been used extensively in developing new programming languages like C#, Java, JavaScript, Perl, UNIX’s C Shell, PHP, Python, and Verilog etc.

  3. Computation Programming - C++ is the best friends of scientists because of fast speed and computational efficiencies.

  4. Games Development - C++ is extremely fast which allows programmers to do procedural programming for CPU intensive functions and provides greater control over hardware, because of which it has been widely used in development of gaming engines.

  5. *Embedded System * - C++ is being heavily used in developing Medical and Engineering Applications like softwares for MRI machines, high-end CAD/CAM systems etc.

这个列表还在继续,在各种领域中,软件开发人员都乐于使用 C 来提供出色的软件。我强烈建议你学习 C,为社区贡献出色的软件。

This list goes on, there are various areas where software developers are happily using C to provide great softwares. I highly recommend you to learn C and contribute great softwares to the community.

Learn C++ By Examples

练习 C 实例是学习 C 编程的最佳方式。我们 C++ 教程的所有章节都有带解释的相关实例。你可以简单地通过这些实例来更好地理解这个概念。

Practicing C examples is the best way to learn C programming. All chapters of our C++ tutorial have the related examples with explanation. You can simply go through those examples to understand the concept better.

Jobs or Careers in C++

C 是一种通用且广泛使用的编程语言。以下是一些你可以在学习 C 编程后获得的职位列表:

C is a versatile and widely used programming language. Here is the list of some job roles that you can get after learning C programming:

  1. Software Engineer

  2. Game Developer

  3. Systems Programmer

  4. Embedded System Developer

  5. Robotics Engineer

  6. Database Developer

  7. Graphics Programmer

以下是雇佣 C++ 开发者的公司列表:

Here is the list of the companies hiring C++ developers:

  1. Microsoft

  2. Amazon

  3. Facebook

  4. IBM

  5. Adobe

  6. Apple

  7. Google

Audience

本 C 教程为初学者准备,旨在帮助他们理解与 C 相关的基础到高级概念。

This C tutorial has been prepared for the beginners to help them understand the basic to advanced concepts related to C.

Prerequisites to Learn C++

在开始练习本 C++ 教程中给出的各种类型的示例之前,我们假设你已经了解计算机程序和计算机编程语言的基础知识。

Before you start practicing with various types of examples given in this C++ tutorial,we are making an assumption that you are already aware of the basics of computer program and computer programming language.

C++ Practice

完成 C++ 教程后,你可以通过以下部分来练习你学到的概念:

After completing the C++ tutorial, you can go through these sections to practice the concepts that you have learned:

C++ STL Library Reference

以下列表包含 C++ STL 库的完整参考−

The following list has the complete reference of C++ STL libraries −

C++ Tutorial Revision

要快速复习 C++ 编程,请通过以下链接进行−

For a quick revision of C++ programming, go through these links −

FAQs on C++ Tutorial

1. What is the easiest way to learn C++ programming?

2. Is prior knowledge of any programming is required to learn C++?

3. What are the important concepts of C++ programming?

4. How much time required to learn C++ programming?

5. Who developed C++ programming language?

6. What was the original name of C++?