?
Solved

prototype for function

Posted on 2006-05-06
3
Medium Priority
?
260 Views
Last Modified: 2010-04-01
another question from review study guide:

In C/C++, the prototype for a function that has no arguments may or may not contain the keyword void:
     int f (void);
     int f( );
a) In C, what is the difference (if any) between using the word void and not using it?
b) Repeat part (a) for C++
0
Comment
Question by:shahrine99
  • 2
3 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 1000 total points
ID: 16623750
Hi shahrine99,

> a) In C, what is the difference (if any) between using the word void
> and not using it?
First case means that function accepts no arguments ... while second means that function arguments are unspecified .. compiler wont be able to generate any type mismatch warnings/errors for the second case

> b) Repeat part (a) for C++
Due to strict type checking, both declarations are equivalent in C++

Cheers!
Sunnycoder
0
 

Author Comment

by:shahrine99
ID: 16623773
thanks sunny! but another thing... C and C++ are equivalent?
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 16623792
> C and C++ are equivalent?
No ... C++ is object oriented ... C is procedural in approach
They are similar but yet quite different
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

839 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