由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - setjmp() and longjmp()
相关主题
a simple question for C++ class请教一个作用域的问题
请问一个exception题目私有成员不能用类成员函数修改?
C++里面compare double to float
两个继承问题[合集] C++问题(copy constructor)
为什么我看不懂下面的code,是不是水平还不够?关于c++的constructor的面试题
C++ 弱问一个问一个简单的C++问题
C++疑问一个指向指针的指针的引用?
two c++ interview questions! (转载)问个char*的问题
相关话题的讨论汇总
话题: longjmp话题: rainbow话题: setjmp话题: kansas话题: endl
进入Programming版参与讨论
1 (共1页)
n**d
发帖数: 9764
1
Why the output is the same after I change longjmp(kansas, 47) to longjmp(
kansas, 0)? The code should not go to "else" becasue the return value is 0
for longjmp(kansas, 0).
#include
#include
using namespace std;
class Rainbow {
public:
Rainbow() { cout << "Rainbow()" << endl; }
~Rainbow() { cout << "~Rainbow()" << endl; }
};
jmp_buf kansas;
void oz() {
Rainbow rb;
for(int i = 0; i < 3; i++)
cout << "there's no place like home" << endl;
longjmp(kansas, 47);
}
int main
t****t
发帖数: 6806
2
不看手册?
DESCRIPTION
longjmp() and setjmp(3) are useful for dealing
with errors and interrupts encountered in a
low-level subroutine of a program. longjmp()
restores the environment saved by the last call
of setjmp(3) with the corresponding env argu-
ment. After longjmp() is completed, program
execution continues as if the corresponding
call of setjmp(3) had just returned the value
val. longjmp() cannot cause 0 to

【在 n**d 的大作中提到】
: Why the output is the same after I change longjmp(kansas, 47) to longjmp(
: kansas, 0)? The code should not go to "else" becasue the return value is 0
: for longjmp(kansas, 0).
: #include
: #include
: using namespace std;
: class Rainbow {
: public:
: Rainbow() { cout << "Rainbow()" << endl; }
: ~Rainbow() { cout << "~Rainbow()" << endl; }

1 (共1页)
进入Programming版参与讨论
相关主题
问个char*的问题为什么我看不懂下面的code,是不是水平还不够?
数组弱问C++ 弱问一个
[合集] 关于构造函数C++疑问
C++菜问: 怎么这样也可以?two c++ interview questions! (转载)
a simple question for C++ class请教一个作用域的问题
请问一个exception题目私有成员不能用类成员函数修改?
C++里面compare double to float
两个继承问题[合集] C++问题(copy constructor)
相关话题的讨论汇总
话题: longjmp话题: rainbow话题: setjmp话题: kansas话题: endl