C++ xcode 4.5 中出现“iostream”文件未找到错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14376525/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 18:17:48  来源:igfitidea点击:

'iostream' file not found error occur in xcode 4.5?

c++iphoneiosxcode

提问by Tirth

i m practising C++. i just add c++ files in XCode and write some string splitting functionality in it. After that i include that C++ file i.e. extension of .mm file in my AppDelegate file and call function from .h file of C++ class. But i found one static error in red line which is 'iostream' file not found. I used latest XCode version 4.5 and iOS 6.0. Please see screen shot of my error or xcode screen. enter image description here

我在练习 C++。我只是在 XCode 中添加 C++ 文件并在其中编写一些字符串拆分功能。之后,我在我的 AppDelegate 文件中包含该 C++ 文件,即 .mm 文件的扩展名,并从 C++ 类的 .h 文件中调用函数。但是我在红线中发现了一个静态错误,即未找到“iostream”文件。我使用了最新的 XCode 4.5 版和 iOS 6.0。请查看我的错误或 xcode 屏幕的屏幕截图。 在此处输入图片说明

I m tried to modify my code as per given linkinformation but no success. :(

我试图根据给定的链接信息修改我的代码,但没有成功。:(

also i followed this linkinformation as well, but result is same.

我也跟着这个链接信息,但结果是一样的。

Thanks iHungry

谢谢 iHungry

采纳答案by arthankamal

Objective Chaving .mextensions for its implementation files. If you want to use C++in Objective Cit should have .mmextensions. you can include C++header files in your .mmfile. But if you want to include your C++header files in your .hfile, you need to check macrofor that, like

Objective C具有.m其实现文件的扩展名。如果你想使用C++Objective C它应该有.mm扩展。您可以C++在文件中包含头.mm文件。但是如果你想C++在你的.h文件中包含你的头文件,你需要检查macro一下,比如

#ifdef __cplus
#include <iostream>
#endif

But, I haven't tried any functions by including C++header file in .hfile. Hope it helps.

但是,我还没有通过C++.h文件中包含头文件来尝试任何功能。希望能帮助到你。