Objective-C 中星号 * 的不同之处

发布于 2025-01-08 17:17:46 字数 278 浏览 4 评论 0原文

目前,我正在开始 iPhone 应用程序开发。所以,我必须重新找回我的 C 知识(这不太好,在拼贴时得到了两次F

在我看了几本教程和书籍之后,我注意到了一些事情,

1. MyClass* myInstance
2. MyClass *myInstance
3. (MyClass *)myInstance

据我所知,所有这些都是指针(如果我没有理解错的话)。但他们每个人之间有什么不同。或者,它们只是相同,但定义方式不同。

Currently, I'm starting an iphone application development. So, I have to retrieve my C knowledge back ( which wasn't good, got F twice back at the collage )

After I went to several tutorials and books, I notice something,

1. MyClass* myInstance
2. MyClass *myInstance
3. (MyClass *)myInstance

So far as I know, all of those are pointer (If I'm not misunderstanding). But what is the different between each of them. Or, they are just the same but define in different ways.

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

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

发布评论

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

评论(1

寄离 2025-01-15 17:17:46

12没有区别 - 取决于您喜欢哪种风格。

3 可以是方法声明或转换语法(感谢 rob mayoff)。

方法声明:https://stackoverflow.com/a/683290/187954

转换:https://stackoverflow.com/a/690760/187954

1, 2 no difference - depends on which style you prefer.

3 could be either a method declaration or the syntax for casting (thanks rob mayoff).

Method declaration: https://stackoverflow.com/a/683290/187954

Casting: https://stackoverflow.com/a/690760/187954

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