pr25001.cpp
来自「c++编程宝典源码及Quincy99编译器 是《标准C++编程宝典》电子工业出」· C++ 代码 · 共 50 行
CPP
50 行
////////////////////////////////////////
// File Name: pr25001.cpp
////////////////////////////////////////
#include <iostream>
// Function prototypes.
void foo();
// Exception class declaration.
class Bummer{};
////////////////////////////////////////
// The main() function.
////////////////////////////////////////
int main()
{
// The try block.
try
{
std::cout << "calling foo" << std::endl;
foo();
std::cout << "return from foo << std::endl";
}
// Catch exception handler.
catch(Bummer)
{
// Error-handling code.
std::cout << "catching Bummer" << std::endl;
}
std::cout << "done" << std::endl;
return 0;
}
////////////////////////////////////////
// Program function.
////////////////////////////////////////
void foo()
{
int error = 1;
// C++ statements to do stuff.
if (error)
{
std::cout << "throwing Bummer" << std::endl;
throw Bummer();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?