随笔分类 - C++
摘要:主要参考官方链接: https://learn.microsoft.com/zh-cn/windows-hardware/drivers/gettingstarted/writing-a-very-small-kmdf--driver 其中注意修改点: 双虚拟机安装好windows10系统(MSDN
阅读全文
摘要:1 #include <iostream> 2 #include <thread> 3 4 void Func() 5 { 6 std::cout << "hello" << std::endl; 7 } 8 9 int main() 10 { 11 //ok 12 //std::thread tm
阅读全文
摘要:1. 静态类方法只需要在类内部使用static,类方法实现cpp 内不需要在到函数头部增加static。 2. 联合体 可见域范围 1 #include <iostream> 2 3 //文件全局可见性 4 union Opval 5 { 6 double dis; //运动距离 7 double
阅读全文
摘要:1 #include <iostream> 2 3 using namespace std; 4 5 class TInterface1 6 { 7 public: 8 virtual void Sleep() = 0; 9 }; 10 class TInterface2 11 { 12 publi
阅读全文
摘要:C++ 线程在进入sleep 之后唤醒会导致延时不准确,测试达到最大38ms 延时,采用组合睡眠方式,最后延时判断阶段能逼近延时情况。 1 #include <iostream> 2 #include <thread> 3 #include <string> 4 #include <ctime> 5
阅读全文
摘要:今天调试程序,发现C++ 数组值无法赋值,断点正常,调试内容就是不对; 反复查看20分钟发现bug 如下(伪代码): int a[2] = {0}; if(con1 true) { a[0] == 100; } else { a[1] == 100; } 错误原因: 将赋值语句多写一个等号变成判断语
阅读全文
摘要:1 #include <iostream> 2 #include <string> 3 4 using namespace std; 5 6 class Base 7 { 8 public: 9 Base() 10 { 11 name = "base"; 12 } 13 Base(string na
阅读全文
摘要:参见微软官方教程: 在 Visual Studio 中创建 C/C++ DLL | Microsoft Docs 演练:创建并使用静态库 (C++) | Microsoft Docs VS2017 创建和使用具有导出项的动态链接DLL库_雪易的博客-CSDN博客_具有导出项的动态链接库 添加库路径设
阅读全文
摘要:1 #include <iostream> 2 #include <vector> 3 4 using namespace std; 5 6 int main() 7 { 8 vector<string> aa; 9 aa.push_back("A"); 10 aa.push_back("B");
阅读全文
摘要:转自:编程最顶的八句格言! - 知乎 (zhihu.com) 格言一:“All problems in computer science can be solved by another level of indirection” 解读:“计算机科学中的所有问题都可以通过增加一个间接层来解决”,出自
阅读全文
摘要:“计算机科学领域的任何问题都可以通过增加一个间接的中间层来解决” “Any problem in computer science can be solved by anther layer of indirection.” ——David Wheeler(剑桥大学计算机科学教授) 1 #inclu
阅读全文
摘要:C++中的 "override" - 简书 (jianshu.com) 1 #include <iostream> 2 3 using namespace std; 4 5 class Hum 6 { 7 protected: 8 string name; 9 public: 10 Hum(stri
阅读全文
摘要:1 template<typename T> 2 void Tarray(std::vector<T>& tt) 3 { 4 tt.push_back(100); 5 } 6 std::vector<int> aa; 7 Tarray<int>(aa); 8 PDmsg(aa[0]); 9 PDms
阅读全文
摘要:1 bool ret = false; 2 3 //Json::FastWriter writer_ob; 4 //std::string jsonStr = writer_ob.write(root); 5 6 std::string jsonStr = root.toStyledString()
阅读全文
摘要:template<typename T, int N> void Print(T value) { for(int i = 0; i < N; i++) cout << value << endl; } using namespace std; int main() { Print<string,
阅读全文
摘要:1 #include <iostream> 2 3 class String 4 { 5 private: 6 char *m_BufMemPtr; 7 int m_BufSize; 8 9 public: 10 String(const char *srcbuf) 11 { 12 m_BufSiz
阅读全文