Objective-C 中的对象与 PHP 中的对象相同吗?

发布于 2024-10-03 02:24:35 字数 190 浏览 3 评论 0原文

我即将开始学习 Objective-C,我想知道这些概念是否与 PHP 相同。例如,面向对象的PHP中的概念是否与Objective-C相同,例如“类、实例、消息、方法、实例变量、继承、超类/子类和协议”?如果是这样,我猜我会更容易学习和掌握,因为我已经了解了面向对象 PHP 的基础知识和基础。或者它们彼此完全不同?

非常感谢任何帮助和建议。谢谢!

I am about to start learning Objective-C and I was wondering whether or not the concepts are the same as with PHP. For example, are the concepts in Object Oriented PHP the same as Objective-C, such as "Class, Instance, Message, Method, Instance Variable, Inheritance, Superclass/Subclass, and Protocol"? If so, this will I am guessing it will be much easier for me to learn and grasp since I already know the basics and foundations of Object Oriented PHP. Or are they completely different from each other?

Any help and advice is greatly appreciated. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

再浓的妆也掩不了殇 2024-10-10 02:24:36

它们基本上是相同的想法,但不是实现,因为其中大多数都是 CS 理论概念。 PHP 中不存在消息和协议。 PHP 具有大多数语言所称的接口,类似于 Objective-C 中的协议。

They are basically the same idea, but not implementation, since most of those are CS theory concepts. Messages and protocols don't exist in PHP. PHP has what most languages call an interface which is akin to a protocol in Objective-C.

将军与妓 2024-10-10 02:24:36

所有“正确的”OO 语言结构本质上应该是相同的。他们应该始终拥有以下内容的全部或一个子部分(可能还有更多)。

  • 类/对象(完全不同)
  • 方法(与函数)
  • 方法可见性/访问控制(公共、私有、受保护)
  • 构造
  • 函数静态/类变量和方法方法
  • 析构函数/终结器
  • 继承(通常是多重继承)
  • 接口/协议
  • 抽象类
  • 重写
  • 重载

还有很多术语与概念性的东西而不是语言功能有关,但这只是一些事情的简短(并且相当不完整)列表对于使用任何值得一试的 OO 语言进行编程,您都应该了解这一点。

如果您愿意,维基百科上有一个很好的术语小列表可以为您提供帮助。
http://en.wikipedia.org/wiki/List_of_object-oriented_programming_terms

我建议阅读上面的术语,以及

  • 实例变量
  • 多态性
  • 组合
  • 封装

如果您知道 OO 的定义,那么从一种语言转向另一种语言要简单得多,因为您将有一个非常广泛的基础,只需要学习微妙的知识差异(就像在了解一些新语言后学习任何新语言一样,但对于 OO 概念更是如此)。

All "propper" OO language constructs should be essentially the same. They should always have all of, or a sub section of the the following (and probably more).

  • class / object (completely different)
  • method (vs function)
  • method visibility/access control (public, private, protected)
  • constructor
  • static/class variables & methods
  • destructor/finalizer
  • inheritance (and often, multiple inheritance)
  • interface/protocol
  • abstract class
  • overriding
  • overloading

there are plenty more terms to do with things that are more conceptual rather than language features, but that's a short (and reasonably incomplete) list of some things that you should know for programming in ANY OO language worth it's salt.

There's a nice little list of terms on Wikipedia to help if you'd like.
http://en.wikipedia.org/wiki/List_of_object-oriented_programming_terms

I'd suggest reading about the terms above, as well as

  • Instance variables
  • Polymorphism
  • Composition
  • Encapsulation

If you know your defenitions of OO, moving from one language to the next is far simpler, because you will have a very wide base to stand on and only have to learn subtle differences (as with learning any new language after knowing a few, but more so with OO concepts).

梦在深巷 2024-10-10 02:24:36

简短的回答是“是”。中等长度的答案已由 Apple 编写,您可以在这里阅读:

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/OOP_ObjC/Introduction/Introduction.html

The short answer is "Yes." The medium-length answer has been written by Apple, and you can read it here:

http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/OOP_ObjC/Introduction/Introduction.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文