|
-
April 29th, 2011, 04:53 PM
#5
Re: about return value
 Originally Posted by talentspsp
For C++ programmers, if a function needs to return a value to indicate MULTIPLE status, such like success and different situations of failure(more than one, so can't return bool), what value should be returned to indicate success in "c++ standard"? Is there such standard?
You can use an enum, but you'll have to be careful to prevent name clashes, since the values defined in an enum are identifiers in the same scope as the enum. To prevent this, you could use http://www.boost.org/doc/libs/1_46_1..._emulation.hpp.
Code:
enum ReturnValue {
Success,
Failure1,
Failure2
};
ReturnValue foo();
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|