类和封装之间有什么区别 [英] what is the difference between class and encapsulation

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

问题描述

我们可以区分类和封装吗?

can we differncitate class and encapsulation

推荐答案

封装本质上是数据隐藏".
类是可以实例化以在内存中创建对象的构造.该类将使用封装(例如公共方法和私有方法)来隐藏您不想允许公共访问的属性.最后,将创建该类的实例.该对象将基于类中的封装显示和隐藏成员.
Encapsulation is essentially "data hiding".

A class is a construct that can be instantiated to create objects in memory. The class will use encapsulation (e.g. public and private methods) to hide attributes that you don''t want to allow public access to. Finally an instance of the class will be created. This object will show and hide members based on the encapsulation set in the class.


否.就像问:"Moon和NASA有什么区别?".

抱歉,但是您没有看到诸如"{0}和{1}之间的区别是什么"之类的问题是不正确的(希望上面的示例可以帮助您实现这一点),我不想进一步讨论与OOP相关的细节.您可以轻松地找到大量有关OOP的文献.您的目标是仅学习什么是类"和封装",这只是浪费时间.

—SA
No. This is the same as to ask: "What''s the difference between Moon and NASA?".

Sorry, but it you don''t see that the questions like "What''s the difference between {0} and {1}" are incorrect (hope my example above helps you to realize that), I don''t want to go into any further OOP-related detail. You can easily find tons of literature about OOP. Of you goal is to learn just about what is "class" and "encapsulation", this is just a waste of time.

—SA


如果您正在网上寻找东西,那么Google是您的朋友.

现在,关于您的问题,请参阅本文,它将清除您的所有疑问:

面向对象的编程概念(OOP)及更多内容的介绍 [
Google is your friend, if you are looking stuffs on web.

Now as far as your question is concerned refer this article, it will clear all your doubts:

Introduction to Object Oriented Programming Concepts (OOP) and More[^]

hope it helps :)


这篇关于类和封装之间有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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