会议的结果,code错误C ++ INT富(...) [英] Convention result and code error C++ int foo (...)

查看:105
本文介绍了会议的结果,code错误C ++ INT富(...)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Linux中,例如,当我使用批处理如果错误code是0这就是好,但什么是在C ++约定?

In Linux for example when i use batch if error code is 0 thats good, but what is the convention in C++ ?

当INT(或布尔)等于一体,我们说这是真的,但什么必须是这样的功能在C ++中的回报?

when int (or bool) is equal to one we say that's true, but what must be the return of such function in C++ ?

推荐答案

在C ++中,通常使用布尔返回指示成功真的,假的失败。

In C++ it is common to use boolean return to indicate true for success, and false for failure.

它也是通常使用的整数返回值,其中零表示成功,以及非零以指示故障或任何其它条件(常常负数可以指示错误,而阳性表明一些其他结果)。

It is also common to use an integer return value where zero indicates success, and non-zero to indicate failure or any other condition (often negative numbers can indicate errors, while positive indicate some other outcome).

无论接近你选择,重要的是记录,并在整个code的基础是一致的。

Whichever approach you choose, the important thing is to document it and be consistent throughout the code base.

这篇关于会议的结果,code错误C ++ INT富(...)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆