代码:
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默认为双精度浮点类型。
原文链接: https://www.cnblogs.com/hu983/p/5537896.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/234154
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!