什么是C ++中的类和对象? [英] What is a Class and Object in C++?

查看:87
本文介绍了什么是C ++中的类和对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是C ++中的类和对象?

What is a Class and Object in C++?

我们可以说类是对象吗?

Can we say that a Class is an Object?

推荐答案

一个类就像一个蓝图,一个对象就像是根据该蓝图建造的房屋。

A Class is like a blueprint, an object is like a house built from that blueprint.

您可以有很多房屋具有相同的布局/平面图(读取类),但每个都是它自己的实例(读取对象)。每个对象都有自己的所有者,家具等。

You can have many houses with the same layout/floorplan (read class), but each is it's own instance (read object). Each has it's own owner, furniture, etc.

请注意,还有一些对象的蓝图不是类(例如整数)。

Note that there are also objects whose blueprint is not a class (e.g. integers).

这篇关于什么是C ++中的类和对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆