This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/78462] feature request: need function default arguments
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 22 Nov 2016 11:52:17 +0000
- Subject: [Bug c++/78462] feature request: need function default arguments
- Auto-submitted: auto-generated
- References: <bug-78462-4@http.gcc.gnu.org/bugzilla/>
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) {
}