Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: using (void...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 10 of 11 Topic 9806 of 10094
Post > Topic >>

Re: using (void) in the parameter list

by Erik Max Francis <max@[EMAIL PROTECTED] > Jul 24, 2008 at 04:08 PM

Seungbeom Kim wrote:

> Alberto Ganesh Barbati wrote:
>> Kush ha scritto:
>>>
>>> RunProgram::RunProgram(void)
>>> {}
>>
>> The use of "(void)" is provided for backward compatibility with C and
is
>> frowned upon in a C++ program. Just write "()".
> 
> I have wondered, why is it frowned upon in a C++ program? I don't see
> any harm there. Did I miss anything? Is it deprecated or anything?
> 
> Actually it may even be better in a header file shared by C and C++,
> because it means exactly the same thing both in C and C++: both f() and
> f(void) in C++ means f(void) in C, but f() in C means something else.
> In addition, in a sense, it's more consistent across the parameter list
> and the return type ("use void to mean nothing").
> 
> I know we really don't have to type the four additional characters,
> but I don't see the point in bothering to point out that it shouldn't
> be used. If there's any, can you please explain it?

The most useful answer would be that the inventor of the language 
intended the empty argument list to mean an empty argument list, not an 
unspecified argument list (as it is in C).  Thus the argument list 
`(void)` is unnecessary and included only for C compatibility.

Scanning through _The C++ Programming Language_ 3e, you'd be hard 
pressed to find Stroustrup even mentioning the backward-compatibility 
syntax.  A quick scan through _Design and Evolution of C++__ also 
doesn't seem to think it significant enough to warrant mention.  It's of 
course indicated in the C++ Standard (8.3.5/2), but only in one sentence 
without fanfare.  And the vast majority of the examples in all three 
books use the empty argument list syntax, not `(void)`.

-- 
Erik Max Francis && max@[EMAIL PROTECTED]
 && http://www.alcyone.com/max/
  San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis
   Grub first, then ethics.
    -- Bertolt Brecht

      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 11 Posts in Topic:
Help with Compile Error :)
Kush <kbubbar@[EMAIL P  2008-07-19 14:42:04 
Re: Help with Compile Error :)
Ian Collins <ian-news@  2008-07-20 01:26:57 
Re: Help with Compile Error :)
Seungbeom Kim <musiphi  2008-07-20 01:22:40 
Re: Help with Compile Error :)
ppizzq <ppizzq@[EMAIL   2008-07-20 06:28:28 
Re: Help with Compile Error :)
ppizzq <ppizzq@[EMAIL   2008-07-20 07:28:12 
Re: Help with Compile Error :)
Alberto Ganesh Barbati &l  2008-07-20 07:28:13 
using (void) in the parameter list
Seungbeom Kim <musiphi  2008-07-20 18:07:10 
Re: using (void) in the parameter list
Alberto Ganesh Barbati &l  2008-07-21 14:40:18 
Re: using (void) in the parameter list
Jiang <goo.mail01@[EMA  2008-07-24 05:12:04 
Re: using (void) in the parameter list
Erik Max Francis <max@  2008-07-24 16:08:13 
Re: using (void) in the parameter list
Seungbeom Kim <musiphi  2008-07-24 16:08:14 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Oct 12 22:21:21 CDT 2008.