平日小问题 (2):[Error] 'setprecision' is not a member of 'std'
2016-05-06 21:56
741 查看
#include <iostream> template <typename t> t sum(t x,t y) { return x+y; } int main() { int a,b; double c,d; std::cin>>a>>b>>c>>d; std::cout<<sum(a,b)<<std::endl; std::cout<<std::fixed<<std::setprecision(3)<<sum(c,d)<<std::endl; }
报错:[Error] ‘setprecision’ is not a member of ‘std’
需要加上头文件 便可通过编译
修改后:
#include <iostream> #include <iomanip> template <typename t> t sum(t x,t y) { return x+y; } int main() { int a,b; double c,d; std::cin>>a>>b>>c>>d; std::cout<<sum(a,b)<<std::endl; std::cout<<std::fixed<<std::setprecision(3)<<sum(c,d)<<std::endl; }
相关文章推荐
- 平日小问题 (1): call of overloaded 'max(char&, char&)' is ambiguous
- 平日小问题(3):分数的求和问题
- PHP mail
- PHP学习之路——数组篇
- vsftpd-3.0.2 x86_64 编译安装
- 三个常用的PHP图表类库
- 【转】PHP 之 CURL 模拟登陆并获取数据
- 【转】php curl 伪造IP来源的实例代码
- PHP根据经纬度,计算2点之间的距离的2种方法
- bootstratp图标的使用
- PHP推荐标准(PSR)
- debian开启php的curl支持
- Thinkphp 关于Behavior的理解
- PHP MysqlI操作数据库
- stristr_strrchr.php
- 配置Windows为NTP服务器
- strstr_strchr.php
- php实习tips(如何生成简单摘要)
- PHP一些函数
- strcasecmp_strnatcmp.php