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 9 of 11 Topic 9806 of 9983
Post > Topic >>

Re: using (void) in the parameter list

by Jiang <goo.mail01@[EMAIL PROTECTED] > Jul 24, 2008 at 05:12 AM

Well, if this post is not that off-posting ...

> 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?
>

Here I agree with Alberto that using void for empty parameter list in
C++ is not a good programming style.

For the following C++ code

     void foo(void){}

I always wondering how much the writer knows the C++ language.
   (and, yes, it does cost 4 extra typing )

Of course, it is an issue of style, YMMV.   :-)


> 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").

IMHO, header file is not an issue there.

Mixing C and C++ requires quite a lot extra work and add the void
only won't help at all for the real-world code. And, even if we must
to mix C and C++, since the void is a must for C and it is better
style to use empty parentheses to distinguish  C++ code from C
code, IMHO.

BTW, in C99, function declarator with empty parentheses is now
an obsolescent feature (6.11.6). It is a good news since less
confusion will be made in the future for this issue.

> 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 only point I can think of is, well, protecting our fingers and
keyboard :-) , but as you mentioned above, why don't we do the
same job using the simple way?

Jiang


-- 
      [ 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 Sat Sep 6 15:40:14 CDT 2008.