Home>Article> What is the difference between C language and C++

What is the difference between C language and C++

清浅
清浅 Original
2019-02-23 16:32:56 24036browse

The differences between C language and C are: C is a process-oriented language, and C is an object-oriented language; in addition, their file suffix names, keywords, function return values, function overloading and parameter lists, etc. They are different in all aspects

For C language and C, many people tend to regard C as an upgraded version of C language. In fact, there is no upgrade or replacement relationship between them. Next, in the article, I will introduce the differences between the two in detail, hoping it will be helpful to everyone.

What is the difference between C language and C++

[Recommended courses:C Language Tutorial,C Tutorial

The difference between C language and C

(1 ) Process-oriented language and object-oriented language

C language is a process-oriented language, that is, it first analyzes the steps to solve the problem and then implements these steps one by one

C is object-oriented Language, that is, dividing the problem into several objects, the purpose is to describe the behavior of something in the steps of solving the entire problem

(2) Different keywords

There are 32 keywords in C language, while C has 63 keywords. In addition, variables defined by the struct keyword in C language cannot have functions, but in C they can have functions

(3) File suffix names are different

In C language The suffix name of the source file is .c, and the suffix name of the C source file is .cpp

(4) The function return value is different

In C language, if a function is not specified Return value type, default returns int type; in C, if a function does not return a value, it must be specified as void

(5) Function overloading

Function overloading is A special case of functions, which refers to declaring several functions of the same name with similar functions in the same scope. The formal parameter lists (number, type, order of parameters) of these functions with the same name must be different, and the return value types can be the same or different. , often used to deal with the problem of implementing similar functions but different data types.

Since the rules of function symbols in C language are generated based on names, it does not have function overloading, while the function symbols generated by C take into account the function name, parameters and parameter types.

So C can determine overloading based on the number of function name parameters and parameter types. It belongs to static polymorphism and must be in the same scope to be called overloading

(6) Parameter list

In C language, when a function does not specify a parameter list, it can receive any number of parameters by default; but in C, due to strict parameter type detection, functions without a parameter list default to void and do not receive any parameters

Summary: The above is the entire content of this article, I hope it will be helpful to everyone.

The above is the detailed content of What is the difference between C language and C++. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn