Skip to content

Instantly share code, notes, and snippets.

@rowanj
Created June 30, 2012 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rowanj/3023854 to your computer and use it in GitHub Desktop.
Save rowanj/3023854 to your computer and use it in GitHub Desktop.
Default arguments aren't overloads
#include <iostream>
using namespace std;
// #include <some header>
void foo(int x, int y);
// but we always use y = 2 with foo
void foo(int x, int y = 2);
int main()
{
foo(1);
}
// and later link to the One Definition of foo
void foo(int x, int y)
{
cout << "x: " << x << " y: " << y << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment