First decision:
If this is a link to a structure, you should make a link constand do this:
struct A
{
A(int, int);
};
void f(int a, const A & = A(10,20) )
{
}
This is not so good for obvious reasons: it makes a parameter const(you may not want it), and your structure should have a constructor (you may not have one).
The second solution:
So, if you do not want to do this const, or if you do not want to have a constructor in the structure, you can do this:
struct Point
{
int x, y, z;
};
Point g_default_point = {10,20,30};
void g(int a, Point & p = g_default_point )
{
}
Still not good. Defining a global variable is a great idea.
:
void g(int a, Point & p)
{
}
void g(int a)
{
Point default_value = {10,20,30};
g(a, default_value);
}
const, .