如:
#include<iostream>
using namespace std;
void func()
{
cout << "func的调用!" << endl;
}
void func(int a)
{
cout << "func(int a)的调用!" << endl;
}
void func(double a)
{
cout << "func(double a)的调用!" << endl;
}
void func(int a,double b)
{
cout << "func(int a,double b)的调用!" << endl;
}
void func(double b,int a)
{
cout << "func(double b,int a)的调用!" << endl;
}
int main()
{
func();
func(5);
func(3.14);
func(5, 3.14);
func(3.14, 5);
system("pause");
return 0;
}
注意:函数返回值不可以作为函数重载的条件。