Hi, all, I have following code: class A { }; class B { public: void foo( A& ra = A() ) { } }; int main() { return 0; }If I compile with g++, it has following error message: invalid type 'A' for default argument to 'A&'.
But when I compile it using SunStudio compiler, it works.I suspect the error is due to set the default value for reference "ra" with a constructor.
Can anyone explain whether the above code is valid in C++ standard ? If not, how to make it work by g++ ?
Thanks.Michael