Any method (within a C++ class) that prints to a file or to a screen has a return type of void. What role does the keyword void perform?
highflyer8
0
Light Poster
Recommended Answers
Jump to PostSeems to me that you need to give us a specific code sample and explain what you are asking. Most of what you said is confusing and (I believe) wrong. But because it's confusing I'm not sure.
Jump to PostGenerally, if a member function accepts a data stream (such as an ofstream) as an argument, it should return the data stream.
@WaltP:
The OP has another thread here:
http://www.daniweb.com/software-development/cpp/threads/353213it seems to be related, I've reported it as a bad post and suggested a merge...
Jump to PostYes, exactly. The two posts are related.
Then don't do that. One problem, one thread.
Jump to PostThe void return type can be thought of as nothing more than a place-holder. The general form of a function declaration/definition is:
[I]returnDataType[/I] functionName([argType arg1, [argType arg2, ...]])
The void type is used in the returnDataType position to indicate that there is no return value. This makes …
Jump to PostOnly partially. This particular method does not return a value, but it's not a general rule. Whether a function returns a value or not depends on how it's declared/defined and how it's intended to be used.
All 19 Replies
Helmyano
0
Newbie Poster
highflyer8
0
Light Poster
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
Fbody
682
Posting Maven
Featured Poster
highflyer8
0
Light Poster
highflyer8
0
Light Poster
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
Fbody
682
Posting Maven
Featured Poster
highflyer8
0
Light Poster
Fbody
682
Posting Maven
Featured Poster
highflyer8
0
Light Poster
Fbody
682
Posting Maven
Featured Poster
highflyer8
0
Light Poster
Fbody
682
Posting Maven
Featured Poster
Fbody
682
Posting Maven
Featured Poster
highflyer8
0
Light Poster
Fbody
682
Posting Maven
Featured Poster
highflyer8
0
Light Poster
Fbody
682
Posting Maven
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.