Skip to content

Instantly share code, notes, and snippets.

@marcoscastro
Created April 6, 2014 20:28
Show Gist options
  • Save marcoscastro/10011131 to your computer and use it in GitHub Desktop.
Save marcoscastro/10011131 to your computer and use it in GitHub Desktop.
parâmetros opcionais em c++
// exemplo do uso de parâmetros opcionais em C++
// www.GeeksBR.com
#include <iostream>
using namespace std;
int inc_num(int n, int add = 0)
{
return n + add;
}
int main()
{
int num = 10;
num = inc_num(num);
cout << num << endl; // imprime 10
num = inc_num(num, 1);
cout << num << endl; // imprime 11
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment