/ Peter 感谢您的回复。 就像你说的断言()用于调试,对于我的情况assert()调用将在优化编译中删除,它只保留在调试版本中。 有一件事我想确定,让'' s说函数调用就像是 这个: func1() - > func2() - > func3() 在func3()中抛出异常,func3()声明抛出 异常。然后为了使func1()接收异常,func2() 必须声明throw expetion。这是对的吗? 这样的更多细节, int func1(){ ... 尝试{ func2(); } 抓住重复{ 。 .. } } int func2()抛出异常{ ^^^ ^^^^^^^^^^^^^ - 我必须有这个声明, 对吗? func3(); } int func3()抛出异常{ ... 抛出异常; } Thanks for the reply. Like you said assert() is for debug, for my case the assert() call willbe removed in optimized compile, it only stays in the debug version. One thing I want to make sure, let''s say the function call is likethis:func1()--> func2()--> func3()In func3() I throw an exception, and func3() declares "throwexception". Then in order for func1() to receive the exception, func2()must declares "throw expetion". Is this right? More details like this, int func1(){...try {func2();}catch excpetion {...}} int func2() throw exception {^^^^^^^^^^^^^^^^ -- I must have this declaration,right?func3();} int func3() throw exception {...throw exception;} 这篇关于断言异常:场景是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-12 16:58