摘要: 在C++11中提供了专门的数值类型和字符串类型之间的转换的转换函数。 数值转换为字符串 使用to_string()方法可以将各种数值类型转换为字符串类型,这是一个重载函,函数声明位于头文件中,函数原型如下: // 头文件 <string> string to_string (int val); st 阅读全文
posted @ 2026-03-04 14:24 ProMonkey; 阅读(26) 评论(0) 推荐(0)
摘要: c++中通过throw关键字抛出异常,通过try{}catch{}捕获异常,在对应函数后添加throw()指定可以抛出的异常类型 #include<iostream> using namespace std; struct MyException { MyException(string str) 阅读全文
posted @ 2026-03-04 08:45 ProMonkey; 阅读(26) 评论(0) 推荐(0)