码迷,mamicode.com
首页 > 编程语言 > 详细

C/C++默认浮点型

时间:2016-05-28 19:12:40      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:

代码:

 1 #include <iostream>
 2 #include <cstdio>
 3 
 4 using namespace std;
 5 
 6 void test(int a){
 7     cout<<a<<endl;
 8 }
 9 void test(float a){
10     cout<<a<<endl;
11 }
12 
13 int main(){
14     
15     test(1);
16     test(c);
17     //test(0.5); //编译不通过,默认为double类型
18     test(0.5f);
19 
20     return 0;
21 }

输出:

1
99
0.5

 分析:

0.5默认为双精度浮点类型。

 

C/C++默认浮点型

标签:

原文地址:http://www.cnblogs.com/hu983/p/5537896.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!