search
HomeCommon ProblemWhat is the difference between C language and C++

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool