兩個或是多個方法且名稱一樣,帶入參數長度以及型態不能相同
#include <iostream>
using namespace std;
void f();
void f(int n1);
void f(int n1, int n2);
void f(int n1, int n2, int n3);
int f(int n1, int n2, double n3);
int main()
{
f();
f(1);
f(1, 1);
f(1, 1, 1);
cout << f(1, 1, 1.0) << endl;
system("pause");
return 0;
}
void f(){ cout << 0 << endl;}
void f(int n1){ cout << n1 << endl;}
void f(int n1, int n2){ cout << n1 + n2 << endl;}
void f(int n1, int n2, int n3){ cout << n1 + n2 + n3 << endl;}
int f(int n1, int n2, double n3){ return n1 + n2 + n3 + 1; }