Default argument using curly braces initializer

Viewed 2751

I have this snippet of code which seems to work well:

class foo{/* some member variables and functions*/};
void do_somthing(foo x={}){}
int main(){
  do_somthing();
}

I used to use void do_somthing(foo x=foo()){} to default the x argument but I see this way ={} in some book or online example(can not remember). Is it totally ok to use it? Is there any difference between the two methods?

1 Answers
Related