Default argument using curly braces initializer
问题 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: foo x=foo() is copy initialization, Initializes an object from another object and foo() is value