By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,898 Members | 2,006 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,898 IT Pros & Developers. It's quick & easy.

Default parameters in typedef for function

P: n/a
Hello,

Does the C++ standard allow default parameters when defining a typedef for a
function type, e.g.

typedef void (*TYPE_Report)(const char* message, const char* details = 0);

This was accepted by MS Visual C++ 6.0, but is rejected in Visual Studio
..NET 2003.
I assume that this change might be because Visual Studio .NET is more C++
standard compliant than previous versions were.
Is this correct?

Is there any way to use default parameters for function types?

thanks
GŁnter

Jul 22 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"Schwarzbauer GŁnter" <sc*********@aon.at> wrote in message
news:2p************@uni-berlin.de...
Hello,

Does the C++ standard allow default parameters when defining a typedef for a function type, e.g.

typedef void (*TYPE_Report)(const char* message, const char* details = 0);

This was accepted by MS Visual C++ 6.0, but is rejected in Visual Studio
.NET 2003.
I assume that this change might be because Visual Studio .NET is more C++
standard compliant than previous versions were.
Is this correct?
Yes.

Is there any way to use default parameters for function types?


Not that I know of.

================================================== =================
ISO/IEC 14882:1998(E)

8.3.6 Default arguments

3 A default argument expression shall be specified only in the
parameter-*declaration*-clause of a function declaration or in
a template*-parameter (14.1). If it is specified in a parameter*-
declaration*-clause, it shall not occur within a declarator or
abstract*-declarator of a parameter*-declaration.(88)
(88) This means that default arguments cannot appear, for
example, in declarations of pointers to functions, references
to functions, or typedef declarations.
================================================== =================

-Mike
Jul 22 '05 #2

P: n/a

"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:cF****************@newsread1.news.pas.earthli nk.net...

"Schwarzbauer GŁnter" <sc*********@aon.at> wrote in message
news:2p************@uni-berlin.de...
Hello,

Does the C++ standard allow default parameters when defining a
typedef for a function type? Yes.


Mike , thanks for the quick answer...

Is there any way to use default parameters for function types?


Not that I know of.


.... although I don't like it.
Seems like this was no accident, but a deliberate decision.
Does someone know why this was decided this way?

GŁnter

Jul 22 '05 #3

P: n/a
Schwarzbauer GŁnter wrote:
[...]
Seems like this was no accident, but a deliberate decision.
Does someone know why this was decided this way?


If somebody does, it would be in comp.std.c++.

V
Jul 22 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.