C++重载
来源:互联网 发布:打车软件有几种 编辑:程序博客网 时间:2024/06/05 12:00
#include<iostream>
using namespace std;
int& max(int& x,int& y)
{
return x<y?y:x;
}
int& counter()
{
static int cnt = 0;
++cnt;
return cnt;
}
extern "C" void print(int a[],int n)
{
for(int i = 0;i<n;i++)
cout<<a[i]<< ' ';
cout<<endl;
}
void print(int a[],int n,char sep)
{for(int i = 0;i<n-1;i++)
cout<<a[i]<<sep;//(i == n-1?'\n':sep)
cout<<a[n]<<endl;
}
void print(int a[],int n,bool b)
{
if(b)
cout<<'[';
cout<<*a;
for(int i = 1;i<n;i++)
cout<<' '<<a[i];
if(b)
cout<<']';
cout<<endl;
}
int main()
{
int a[5] = {11,22,33,44,55};
print(a,5);//11 22 33 44 55
print(a,5,',');//11,22,33,44,55
print(a,5,true);//[11 22 33 44 55]
print(a,5,false);
int m = 10,n = 20;
max(m,n)+=80;
cout<<m<<','<<n<<endl;
counter() = 1000;
cout<<counter()<<endl;
}
0 0
- C 重载
- C++<<重载
- C++-运算符重载
- C/C++ 函数重载
- [C++]重载运算符
- c++(重载、覆盖、隐藏)
- C语言的重载
- [c++]函数重载
- C++:函数重载
- Objective-C函数重载
- C符号重载
- c++(重载、覆盖、隐藏)
- c++(重载、覆盖、隐藏)
- c++(重载、覆盖、隐藏)
- c++(重载、覆盖、隐藏)
- c++(重载、覆盖、隐藏)
- C#:运算符重载
- c++(重载、覆盖、隐藏)
- IOS开发缓存机制之—内存缓存机制
- JAVA面试题大全整理
- android studio 使用NDK
- KM(n^4)模板
- javascript继承
- C++重载
- 设置navigationbar透明
- HDU 3991 Harry Potter and the Present II(Floyd+DAG最小路径覆盖)
- android面试题目2
- C语言进阶
- 图的遍历
- http://blog.csdn.net/innost?viewmode=contents
- ios打印NSInteger的时候去除警告
- 解决 RMContainerAllocator: Exception while unregistering java.lang.NullPointerException问题