对象和实例的区别 [英] Difference between object and instance

查看:35
本文介绍了对象和实例的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有人有人问过这种问题之前,但我还是觉得答案对我来说太含糊了(以及,通过扩展,一些/大多数初学者)掌握.

I know this sort of question has been asked before, but I still feel that the answer is too ambiguous for me (and, by extension, some/most beginners) to grasp.

我一直在尝试自学比过程和基本 OOP 更广泛的编程概念.我了解 OOP 的具体概念(您创建一个具有数据(成员)和函数(方法)的类,然后在运行时实例化该类以实际执行诸如此类的事情).

I have been trying to teach myself broader concepts of programming than procedural and basic OOP. I understand the concrete concepts of OOP (you make a class that has data (members) and functions (methods) and then instantiate that class at run time to actually do stuff, that kind of thing).

我想我知道类是什么(某种设计蓝图,用于在编译时按照其样式创建实例).但如果是这样的话,什么是对象?我也知道在基于原型的语言中,这可能会使事情变得更糟,但也许这就是为什么我需要明确区分对象和实例的原因.

I think I have a handle on what a class is (sort of a design blueprint for an instance to be created in its likeness at compile time). But if that's the case, what is an object? I also know that in prototype based languages, this can muck things up even more, but perhaps this is why there needs to be a clear distinction between object and instance in my mind.

除此之外,我还在纠结对象"和实例"的概念.我读过的很多资源(包括 SO 上的答案)都说它们基本相同,区别在于语义.其他人说这两者之间存在真正的概念差异.

Beyond that, I struggle with the concepts of "object" and "instance". A lot of resources that I read (including answers at SO) say that they are largely the same and that the difference is in semantics. Other people say that there is a true conceptual difference between the two.

SO 的专家能否帮助初学者在 OOP 世界中获得啊哈"时刻?

Can the experts here at SO help a beginner have that "aha" moment to move forward in the world of OOP?

注意:这不是家庭作业,我不去上学 - 但是,我认为它会帮助正在寻找家庭作业帮助的人.

Note: this isn't homework, I don't go to school - however, I think it would help people that are looking for homework help.

推荐答案

房屋设计的蓝图就像类描述.根据该蓝图建造的所有房屋都是该类的对象.给定的房子是一个实例.

A blueprint for a house design is like a class description. All the houses built from that blueprint are objects of that class. A given house is an instance.

这篇关于对象和实例的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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