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;
}

  

posted @ 2019-09-18 22:28  路边的十元钱硬币  阅读(358)  评论(0编辑  收藏  举报