我应该使用哪个头文件而不是#include <bits / stdc ++。h>

卡琳娜(Karina K)
#include <iostream>
#include <string>
#include <sstream>
//#include <bits/stdc++.h>
#include <iomanip>      // std::setprecision
#include <math.h> 
using namespace std;

我想删除标头#include <bits/stdc++.h>,因为它会大大减慢我的编译时间。

删除它时,出现以下错误:

error: cannot convert ‘long double*’ to ‘double*’ for argument ‘2’ to ‘double modf(double, double*)’
       fractpart = modf(val, &intpart);

我认为问题在于缺少头文件,但不知道它是哪一个。

我得到错误的代码是:

fractpart = modf(val, &intpart);
if (fractpart != 0) {
    throw Error("ERR");
}
Angew不再为SO感到骄傲

此类问题的解决方案是针对所讨论的功能咨询适当的参考。一个广受好评的C ++参考站点是cppreference.com在这种情况下,其参考modf始于:

在标头中定义 <cmath>

有你的答案。

比较在C ++头定义的C ++版本(一个家庭的重载函数)将上述参考<cmath>为C版本参考在C头限定<math.h>

float modff( float arg, float* iptr );
double modf( double arg, double* iptr );
long double modfl( long double arg, long double* iptr );

C没有函数重载,所以modf<math.h>只有double版本。<cmath>,是C ++,声明所有的3 C ++重载(floatdoublelong double),其中您使用的最后一个。

这实际上是避免使用C标准库标头(<*.h>)和使用C ++标准库标头(的原因之一<c*>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

为什么不#include <bits / stdc ++。h>?

#include <bits / stdc ++。h>在C ++中如何工作?

Visual Studio的#include <bits / stdc ++。h>无法编译

为什么 #include<bits/stdc++.h> 默认在 Windows 上不起作用?

为什么在使用“ using namespace std;”时在此代码中出现错误?和“ bits / stdc ++。h”?

如何在Xcode中包含<bits / stdc ++>

无法使用 g++ 编译头位/stdc++11

Android CMake“严重错误:找不到'bits / libc-header-start.h'文件”

我什么时候应该同时写 'winuser.h' 和 'windows.h' 头文件?

编译HTK时出现“严重错误:bits / libc-header-start.h:无此类文件或目录”

链接错误STDC ++

使用静态库(.a)中的头文件(.h)

来自Stg.h的GHC / GCC编译器问题__STDC_VERSION__ w / C99,对于每个软件包均失败

头文件中定义了多个结构-我应该将它们移到单独的h和cpp文件中吗

lib32stdc ++ 6软件包取决于gcc基础,但我安装的版本较新

什么是“ pch.h”,为什么需要将其包含为第一个头文件?

我们可以使用头文件而不指定其.h扩展名吗

当我应该使用render时:h => h(App)?

使用 wingdi.h 时应该链接哪个静态库?

我必须包含哪个头文件才能在内核源文件中获取printk()?

包含没有“.h”格式的头文件

我怎么知道哪个unistd.h文件被加载?

我应该删除.h文件中的char数组吗?

在iOS项目中混合stdc ++和libc ++

自动工具,stdc ++ fs,误报

在Ubuntu中的32位上交叉编译64位程序时缺少“ bits / c ++ config.h”

在Linux中我应该使用什么代替Windows.h

无法从我的Swift控制器引用框架.h头文件

QtCreator 找不到属于我的项目的头文件 (.h)