Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

"void" vs "()"

Posted on 1999-07-23
4
Medium Priority
?
244 Views
Last Modified: 2010-05-18
What does "void" actually mean when it's passed as the only parameter to a function?  Is it the same as empty parentheses?

I am writing code to process C++ source and am trying to decide whether to treat the two the same.

miredo
0
Comment
Question by:miredo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 23

Expert Comment

by:naveenkohli
ID: 1200927
it means the same...
EMPTY  ()...:)
0
 

Expert Comment

by:frogman_j
ID: 1200928
Everyplace I've seen it it's never done anything at all. As far as I know it's pretty much the same.
0
 
LVL 3

Accepted Solution

by:
cwrea earned 200 total points
ID: 1200929
Looking at a Draft version of the C++ standard (I don't have the final one handy :-) it states in section 8.3.5:

If the parameter-declaration-clause terminates with an ellipsis, the number of arguments shall be equal to or greater than the number of parameters specified; if it is empty, the function takes no arguments.  The parameter list (void) is equivalent to the empty parameter list.  Except for this special case, void shall not be a parameter type (though types derived from void such as void*, can). (etc...)

Hope this helps.


0
 

Author Comment

by:miredo
ID: 1200930
Yes, it helps, thanks.

miredo
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

664 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question