博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
example
阅读量:2155 次
发布时间:2019-05-01

本文共 869 字,大约阅读时间需要 2 分钟。

函数声明

#include
using namespace std;int max(int a, int b); // 函数声明int main() { int a = 10, b = 8,t; t = max(a, b); cout << t << endl; cout << "max value:" << t << endl; return 0;}int max(int a, int b) { if (a >= b) return a; return b;}

重载

#include
using namespace std;int max(int a, int b); // 函数声明long max(long a, long b); // 函数声明int main() { int a = 10, b = 8,t; t = max(a, b); cout << "int max value:" << t << endl; long aa = 20, bb = 25, tt; tt = max(aa, bb); cout << "long max value:" << tt << endl; return 0;}int max(int a, int b) { if (a >= b) return a; return b;}// 取最大值+10long max(long a, long b) { if (a >= b) return a+10; return b+10;}

 

默认参数

#include
using namespace std;void create(int n=100); // 默认参数100int main() { create(); //print 100 create(50); // print 50 return 0;}void create(int n) { cout << "create param :" << n << endl;}

 

 

 

 

 

 

 

 

转载地址:http://phxwb.baihongyu.com/

你可能感兴趣的文章
Chrome开发者工具
查看>>
【LEETCODE】102-Binary Tree Level Order Traversal
查看>>
【LEETCODE】106-Construct Binary Tree from Inorder and Postorder Traversal
查看>>
【LEETCODE】202-Happy Number
查看>>
和机器学习和计算机视觉相关的数学
查看>>
十个值得一试的开源深度学习框架
查看>>
【LEETCODE】240-Search a 2D Matrix II
查看>>
【LEETCODE】53-Maximum Subarray
查看>>
【LEETCODE】215-Kth Largest Element in an Array
查看>>
【LEETCODE】241-Different Ways to Add Parentheses
查看>>
【LEETCODE】312-Burst Balloons
查看>>
【LEETCODE】232-Implement Queue using Stacks
查看>>
【LEETCODE】225-Implement Stack using Queues
查看>>
【LEETCODE】155-Min Stack
查看>>
【LEETCODE】20-Valid Parentheses
查看>>
【LEETCODE】290-Word Pattern
查看>>
【LEETCODE】36-Valid Sudoku
查看>>
【LEETCODE】205-Isomorphic Strings
查看>>
【LEETCODE】204-Count Primes
查看>>
【LEETCODE】228-Summary Ranges
查看>>