摘要: 参见:https://en.cppreference.com/w/cpp/algorithm/find 查找指定字符/数字等。 阅读全文
posted @ 2019-09-18 23:00 路边的十元钱硬币 阅读(2953) 评论(0) 推荐(0) 编辑
摘要: 参见:https://en.cppreference.com/w/cpp/algorithm/find std::npos 表示 size_t 的最大值,常用于对查找结果成功与否的判断。 阅读全文
posted @ 2019-09-18 22:59 路边的十元钱硬币 阅读(1483) 评论(0) 推荐(0) 编辑
摘要: 参见:https://zh.cppreference.com/w/cpp/algorithm/remove 使用 erase 和 remove 配合。 输出结果是: Textwithsomespaces 阅读全文
posted @ 2019-09-18 22:52 路边的十元钱硬币 阅读(3097) 评论(0) 推荐(0) 编辑
摘要: 参见:https://zh.cppreference.com/w/cpp/algorithm/remove std::remove 不会改变输入vector / string 的长度。其过程,相当于去除指定的字符(以string为例),剩余字符往前靠。后面的和原始字符保持一致。详见示例程序结果 输出 阅读全文
posted @ 2019-09-18 22:49 路边的十元钱硬币 阅读(3801) 评论(1) 推荐(0) 编辑
摘要: 声明和实现在一个文件中: 声明和实现分开在h和cpp文件中: 潜在问题是,仅仅按照普通class的方式分开,在编译的时候,会报 link2019 错误。原因是在编译实例化模板类的文件时,模板类只有声明文件(h)被链接,其实现文件(cpp里面的部分)找不到。 解决办法: * 1 在实例化模板类的文中开 阅读全文
posted @ 2019-09-18 22:40 路边的十元钱硬币 阅读(743) 评论(0) 推荐(0) 编辑
摘要: #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" << 阅读全文
posted @ 2019-09-18 22:28 路边的十元钱硬币 阅读(358) 评论(0) 推荐(0) 编辑