Specifically, is the following legal C++?
class A{}; void foo(A*); void bar(const A&); int main(void) { foo(&A()); // 1 bar(A()); // 2 }
It a
It is legal. We use it sometime to provide a default value which we might want to ignore.
int dosomething(error_code& _e = ignore_errorcode()) { //do something }
In the above case it will construct an empty error code object if no error_code is passed to the function.
error_code