编译C ++代码时出现ios :: nocreate错误 [英] ios::nocreate error while compiling a C++ code

查看:1876
本文介绍了编译C ++代码时出现ios :: nocreate错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

同时,编译一个在RHEL 5.0上用C ++编写的软件包。我收到以下错误。

While, compiling a package, written in C++ on RHEL 5.0. I am getting the following error.

>错误: nocreate 不是 std :: ios

> error: nocreate is not a member of std::ios

源代码对应于:


ifstream tempStr( argv [4] ios :: in | ios :: nocreate );


我试过了


#g ++ -O -Wno-deprecated< file.cpp> ; -o< file>

#g++ -O -Wno-deprecated <file.cpp> -o <file>

以及:


#g ++ -O -o< file>

#g++ -O -o <file>

请提出解决方案

推荐答案

ios :: nocreate 不是标准C ++的一部分 - 你希望它做什么?

ios::nocreate is not part of standard C++ - what are you expecting it to do?

编辑:从Google,似乎它的目的是防止创建的文件,如果它不存在。这是ifstreams的默认值,所以你可以这样说:

From a Google, it seems like it was intended to prevent the file being created if it doesn't already exist. This is the default for ifstreams anyway, so you can just say:

ifstream f( filename );
if ( ! f.is_open() ) {
    // open failed - probably because infput file does not exist  
}

这篇关于编译C ++代码时出现ios :: nocreate错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆