02 2020 档案
摘要:子类继承了父类的virtual函数,孙子类继承了子类的这个函数,那么孙子类就继承了virtual。 看代码: class base { public: base() = default; virtual ~base() = default; virtual void foo(int (&)[4])
阅读全文
摘要:举个例子: #include <stdio.h> #include <stdlib.h> #include <functional> using FUNC = std::function<int(int, int)>; int foo(int a, int b) { printf("%d\n", a
阅读全文
摘要:有时候为了编译通过,会写一些打桩的接口,桩接口中的从参数都是不用的,所以对于不用的参数习惯是注释掉,或者省略掉,但是最近这样做确遇到了一个错误 error: parameter name omitted这里参考了http://blog.sina.com.cn/s/blog_5f35912f0100v
阅读全文
摘要:百度知道上的用法 // function::target example #include <iostream> // std::cout, std::boolalpha #include <functional> // std::function, std::plus, std::minus in
阅读全文
摘要:转载:https://zhuanlan.zhihu.com/p/24986203 搜索思想——DFS & BFS DFS(Deep First Search)深度优先搜索。 BFS(Breath First Search)广度优先搜索。 今天想说一说个人对于这两个搜索方法的见解。在我看来,DFS与B
阅读全文
摘要:200. 岛屿数量 给定一个由 '1'(陆地)和 '0'(水)组成的的二维网格,计算岛屿的数量。一个岛被水包围,并且它是通过水平方向或垂直方向上相邻的陆地连接而成的。你可以假设网格的四个边均被水包围。 示例 1: 输入:11110110101100000000 输出: 1示例 2: 输入:11000
阅读全文
摘要:static_cast只能进行基本类型之间的转换吗? #include <iostream> using namespace std; typedef struct { int a; } Base; typedef struct _Drive: public Base { int stSMacDB;
阅读全文
摘要:指针相减,结果可能不如你想的那样!!! #include <stdio.h> int main() { int a = 10; int b = 11; printf("a:%p\n",&a); printf("b:%p\n",&b); int* p1 = &a; int* p2 = &b; prin
阅读全文