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

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

问题描述

我知道这类问题已经提出了 之前,但我仍然觉得答案对我来说太含糊(以及扩展名,是一些/大多数初学者).

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天全站免登陆