This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/78462] feature request: need function default arguments


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) {
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]