[Bug c++/78462] feature request: need function default arguments
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Nov 22 11:52:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78462
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution|--- |INVALID
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jim Michaels from comment #0)
> #include <string>
> const std::string test="wish";//global var or const, but const gives me
> headaches
> a(int b, int wish1=2, const wish2=test) {
> ...
> }
This doesn't compile because "const wish2" is not a valid type, you haven't
defined any type called wish2. Your function is also missing a return type.
If you write valid C++ it works fine:
#include <string>
const std::string test="wish";
int a(int b, int wish1=2, const std::string wish2=test) {
}
More information about the Gcc-bugs
mailing list