由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - C++ Exception Question
相关主题
好奇:有多少男人
相关话题的讨论汇总
话题: c++话题: exception话题: question话题: error话题: what
进入Programming版参与讨论
1 (共1页)
r**u
发帖数: 1567
1
Asked during interview.
What is the advantage of using exception over just return error from the
function?
May be a naive question. I am not very familiar with C++ exception.
S**I
发帖数: 15689
2
The C++ Programming Language (3rd Edition) 14.1:
"return an error value," isn't always feasible because there is often no
acceptable "error value." For example, if a function returns an int, every
int might be a plausible result. Even where this approach is feasible, it is
often inconvenient because every call must be checked for the error value.
This can easily double the size of a program. Consequently, this approach is
rarely used systematically enough to detect all errors.

【在 r**u 的大作中提到】
: Asked during interview.
: What is the advantage of using exception over just return error from the
: function?
: May be a naive question. I am not very familiar with C++ exception.

r**u
发帖数: 1567
3
谢谢。经验还是不够啊,我们工作上都基本不用exception。。。

is
.
is

【在 S**I 的大作中提到】
: The C++ Programming Language (3rd Edition) 14.1:
: "return an error value," isn't always feasible because there is often no
: acceptable "error value." For example, if a function returns an int, every
: int might be a plausible result. Even where this approach is feasible, it is
: often inconvenient because every call must be checked for the error value.
: This can easily double the size of a program. Consequently, this approach is
: rarely used systematically enough to detect all errors.

d**********x
发帖数: 4083
4
很多地方都不怎么用exception...
所以可以学点java...

【在 r**u 的大作中提到】
: 谢谢。经验还是不够啊,我们工作上都基本不用exception。。。
:
: is
: .
: is

n******t
发帖数: 4406
5
说实话,他这么写是一回事,别的也就不说了,他真的脑子里面认为用
exception会让代码量变少???
每当我看见这种不靠谱的话,我就在怀疑C++的未来如何。

is
.
is

【在 S**I 的大作中提到】
: The C++ Programming Language (3rd Edition) 14.1:
: "return an error value," isn't always feasible because there is often no
: acceptable "error value." For example, if a function returns an int, every
: int might be a plausible result. Even where this approach is feasible, it is
: often inconvenient because every call must be checked for the error value.
: This can easily double the size of a program. Consequently, this approach is
: rarely used systematically enough to detect all errors.

m*********t
发帖数: 527
6
我觉得不如问问 c++ exception 的 disadvantage 。。。。
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#
"We do not use C++ exceptions"
d****i
发帖数: 4809
7
haha, we don't use C++ exceptions either.

【在 m*********t 的大作中提到】
: 我觉得不如问问 c++ exception 的 disadvantage 。。。。
: http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#
: "We do not use C++ exceptions"

1 (共1页)
进入Programming版参与讨论
相关主题
好奇:有多少男人
相关话题的讨论汇总
话题: c++话题: exception话题: question话题: error话题: what