gpt4 book ai didi

c++ - 在 iPhone 上运行 C++ 有什么限制?

转载 作者:太空狗 更新时间:2023-10-29 20:01:19 26 4
gpt4 key购买 nike

我非常喜欢 C++,老实说,C 的 Objective-C“ super 集”更像是一个“ super 失败”。 iPhone 应用程序可以用纯 C++ 编写吗? API 中是否有 C++ 不可用的部分?

最佳答案

您不能只用 C++ 编写代码。其一,每个应用程序都需要继承的 UIApplicationDelegate 类是 Objective-C。

但是,没有什么可以阻止您编写与 Objective-C++ 框架无关的所有内容。您仍然需要对 UIKit 和其他框架使用 Objective-C 调用,但您的所有应用程序逻辑都可以使用 C++。

来自Objective-C++ section Objective-C 编程指南的主要局限性如下:

Objective-C++ does not add C++ features to Objective-C classes, nor does it add Objective-C features to C++ classes. For example, you cannot use Objective-C syntax to call a C++ object, you cannot add constructors or destructors to an Objective-C object, and you cannot use the keywords this and self interchangeably. The class hierarchies are separate; a C++ class cannot inherit from an Objective-C class, and an Objective-C class cannot inherit from a C++ class. In addition, multi-language exception handling is not supported. That is, an exception thrown in Objective-C code cannot be caught in C++ code and, conversely, an exception thrown in C++ code cannot be caught in Objective-C code. For more information on exceptions in Objective-C, see “Exception Handling.”

关于c++ - 在 iPhone 上运行 C++ 有什么限制?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1765310/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com