C++ try catch 示例代码

#include<iostream>

void f1()
{
	throw std::string("error happen");
}

void f2()
{
	try
	{
		f1();
	}
	catch (...)
	{
		throw;
	}
}

void f3()
{
	f2();
}


int main()
{
	try
	{
		f3();
	}
	catch (...)
	{
		std::cerr << "p" << std::endl;
	}

	return 0;
}

  

原文地址:https://www.cnblogs.com/alexYuin/p/11546030.html