摘要: 1.快速排序 1 int* partition2(int* begin, int* end) { 2 auto* p = begin; 3 if (begin != end) { 4 auto* last = end - 1; 5 while (p != last) { 6 if (p < last 阅读全文
posted @ 2020-07-13 00:13 暗夜追月 阅读(127) 评论(0) 推荐(0) 编辑
摘要: static std::string WCharToAnsi(const wchar_t* src) { std::string ret = ""; const auto size = WideCharToMultiByte(CP_ACP, 0, src, -1, nullptr, 0, nullp 阅读全文
posted @ 2019-01-02 16:00 暗夜追月 阅读(802) 评论(0) 推荐(0) 编辑
摘要: 本测试环境为VS2015。支持C++11标准。 一般的我们通过指针或引用在C++中实现多态。如果要把数据存入容器,则可以使用智能指针。 如果要确保对象可以正常析构,则需要将父类的析构函数声明为虚函数。这样通过父类指针delete时,可确保子类对象的析构函数被正常调用。 正常情况下的执行结果如下图所示 阅读全文
posted @ 2018-12-25 13:44 暗夜追月 阅读(1177) 评论(0) 推荐(0) 编辑
摘要: 最近在学习多线程,题目源自 MoreWindows先生的 《秒杀多线程第一篇》(http://blog.csdn.net/morewindows/article/details/7392749) 题目摘录: 第五题(Google面试题) 有四个线程1、2、3、4。线程1的功能就是输出1,线程2的功能 阅读全文
posted @ 2017-12-06 19:20 暗夜追月 阅读(2873) 评论(0) 推荐(0) 编辑
摘要: 本文参考了http://blog.csdn.net/zdarks/article/details/46994767的代码,并作出适当修改。 Semaphore.h Semaphore.cpp 阅读全文
posted @ 2017-12-03 14:47 暗夜追月 阅读(1305) 评论(0) 推荐(0) 编辑