English 中文(简体)
公约结果和编码错误 C++t foo(......)
原标题:Convention result and code error C++ int foo (...)

例如,在短链氯化石蜡中,如果错误代码为0兆赫,那么当一使用批量时,公约在C++中究竟是什么?

当暗中(或ool)等于我们说是真实的,但必须在C++恢复这种功能?

问题回答

在C++中,通常使用豆类回归来表明成功的真实性,并伪造失败。

在零表示成功的情况下,通常使用分类账回报值,而非零则表明失败或任何其他情况(通常的负面数字可以显示错误,而正面表示其他一些结果)。

无论你选择哪一种办法,重要的是将其记录下来,并在整个法典基础保持一致。

在C及其运行时间图书馆 0 是指成功(有时需要投票机)。

在C++世界中,更加肤色:

  • bool for success/failure
  • enumeration if there are more states
  • exceptions for ... well exceptional cases and object construction/destruction; sometimes they are not available or allowed (mostly embedded platforms, sometimes games to maximize performance)

DON 混合包料使用公约和“0”结果只是简单混淆法(见例子)。 如果你们需要多面的价值观使用点,则视情况而定,需要额外的回归参数或例外。

1. 采用ool和0码混淆:

// sorry for abuse of "C" for educational purposes
bool isSame(s1,s2) { return s1==s2; }
int isSame2(s1, s2) { return strcmp(s1.cstr(), s2.cstr()); } 

if (isSame(..) && !isSame2(..)) ...

C++功能或方法可返回<代码>bool。 页: 1 方案(即<代码>main功能)必须交回<编码>int数值,例如0,以报告成功与否。

标准 重新分类的C类功能,如果成功,通常回报大于或等于零,而失败则恢复到-1。 当1-1被送回时,通常会确定<代码>errno,以提供更具体的错误。 零表示取得了普遍的成功,认为数字大于零,提供了更多的细节。

考虑如下内容:recv from()。 1-1的回报价值表明,在详细代码上,存在直接故障。 零的回报价值意味着,车库被有序关闭,额外电话不会退回数据。 收益价值大于零,这意味着收到数据,收到的 by数目是所回的。

我理解你要问两个问题:

  • how do you return program status in c++
  • how do functions return status in c++

基本答案如下。

典型的情况是,方案(主要)成功回报0,其他价值——错误——失败

如果一项职能能够成功或失败,则通常称为booltrue

如果一项功能能够回馈多种价值,则通常会退回int<>/strong>或t值。

对那些例外的情况提出例外。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?