1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
#include <iostream>
void foo(int a, int b = 10, float c = 0.0f);
void foo(int a, float b = 3.14f);
int main()
{
std::cout << "Invoking foo(5, 6): ";
foo(5, 6);
std::cout << "\nInvoking foo(8): ";
foo(8);
std::cout << "\nInvoking foo(7, 2, 8);: ";
foo(7, 2, 8);
}
void foo(int a, int b, float c)
{
std::cout << " --> I'm foo(int a, int b = 10, float c = 0.0f):\n"
" --> a: " << a << "; b: " << b << "; c: " << c << '\n';
}
void foo(int a, float b)
{
std::cout << " --> I'm void foo(int a, float b = 3.14f):\n"
" --> a: " << a << "; b: " << b << '\n';
}
|