Home  >  Article  >  Backend Development  >  What is the definition of class in c++

What is the definition of class in c++

hzc
hzcOriginal
2020-06-19 17:37:169112browse

What is the definition of class in c++

What is the definition of class in c?

It is to define data of a class type. Class type is a significant feature of C language. , which is not available in C language.

For example, a class is equivalent to the type we talk about in real life. For example, if we define the class "people", then people include men and women; or they can be seen as including the elderly, adults, and children; or they can be seen as Including good guys and bad guys. etc. . .

The same is true in C language. To define a class Class is to define a class of different data objects with common characteristics. This object is called a data member, and the function that operates on this data member is called a member function. That's it. , they are combined to form an abstract data type, a class type.

In short, a class is an abstraction of the common properties and operations of a group of objects. Classes represent generality, while each object of a class represents specificity.

为了在程序中创建对象,首先必须定义类。C++语言用保留字class定义一个类,一般形式为:
class 类名
{
public:
<共有数据和函数>
protected:
<保护数据和函数>
private:
<私有数据和函数>
};
这就是类的定义

Recommended tutorial: "c "

The above is the detailed content of What is the definition of class in 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