Objective-C 中星号 * 的不同之处
目前,我正在开始 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1、2没有区别 - 取决于您喜欢哪种风格。
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