上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 90 下一页
摘要: <template> <div class="test"> test </div> </template> <script> export default { name: "Test", props: [''], components: {}, data() { return {}; }, befo 阅读全文
posted @ 2021-05-13 17:11 王清河 阅读(507) 评论(0) 推荐(0)
摘要: string.cpp /* String 类 */ class String { public: String(const char*str=NULL); //构造函数 String(const String &str); //拷贝构造函数 ~String(); //析构函数 String oper 阅读全文
posted @ 2021-05-07 20:01 王清河 阅读(209) 评论(0) 推荐(0)
摘要: 循环引用指的是使用多个智能指针 shared_ptr 时,出现了指针之间的相互指向,从而形成环的情况,类似于死锁现象,在这种情况下智能指针往往不能正常调用对象的析构函数,从而造成内存泄漏; #include<iostream> #include<memory> using namespace std 阅读全文
posted @ 2021-04-25 10:22 王清河 阅读(1864) 评论(0) 推荐(1)
摘要: C 模拟 C++ 的多态特性(指向派生类的基类指针在调用虚函数时是派生类重写的函数) 利用的是函数指针,因为 C 的 struct 是不能有函数的(C++ 的struct可以) #include<iostream> using namespace std; struct A{ virtual voi 阅读全文
posted @ 2021-04-23 11:16 王清河 阅读(484) 评论(0) 推荐(0)
摘要: 对于push_back和emplace_back在数组尾后添加元素的区别: #include<vector> #include<string> #include<iostream> using namespace std; struct Person{ string name; int age; / 阅读全文
posted @ 2021-04-23 11:13 王清河 阅读(180) 评论(0) 推荐(0)
摘要: # const char* 、 char * 和 string 相互转换 1. string 转 const char* string s = "abc"; //const char* => string const char *s = s.c_str(); //string 转成 char* 直接 阅读全文
posted @ 2021-04-16 20:58 王清河 阅读(1579) 评论(0) 推荐(0)
摘要: strcpy 和 memcpy 的区别 源码实例: #include<cstdio> #include<cstring> #include<cassert> char *myStrcpy(char* dest, const char* src){ if ((NULL == dest) || (NUL 阅读全文
posted @ 2021-04-14 23:08 王清河 阅读(132) 评论(0) 推荐(0)
摘要: 1. 重写 == 操作符 #include<iostream> using namespace std; struct A{ char ch; int val; friend bool operator==(const A &ob1, const A &ob2); bool operator==(c 阅读全文
posted @ 2021-04-10 17:04 王清河 阅读(865) 评论(0) 推荐(0)
摘要: ubuntu18(g++、gdb) #include<iostream> #include<stdio.h> using namespace std; int main(){ int x = 1; int y = 2; int &b = x; return 0; } 编译带参数 -g gdb ./程 阅读全文
posted @ 2021-04-10 15:42 王清河 阅读(189) 评论(0) 推荐(0)
摘要: + 宏主要是用于定义常量及书写复杂的内容;typedef 主要定义类型别名; + 宏替换发生在预处理阶段,属于文本插入替换;typedef 是编译的一部分; + 宏不检查类型; typedef 会检查数据类型; + 宏不是语句,不在结尾处加分号; typedef 是语句,要加分号标识结束; + 注意 阅读全文
posted @ 2021-04-08 20:17 王清河 阅读(239) 评论(0) 推荐(0)
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 90 下一页