C++
alan-img
技术砖家
展开
-
C++的STL适配器的实现原理
在C++的算法中,每个仿函数,都必须要继承binary_function 或者unary_function这两个类, 这两个函数都是定义typedef定义;这里可以看源码;template<class _Arg1, class _Arg2, class _Result> struct binary_function { // base class for binary...原创 2019-07-20 22:29:37 · 249 阅读 · 0 评论 -
引用的本质和C++类封装的原理;
引用的本质和C++类封装的原理, 谈到这个问题就要,首先连接长指针变量;即型如int* const p,他表示的是p的指向不可变,指向的内容可读可写; int a = 10; int * const p = &a; *p = 20; cout << *p << endl;而如果使用const int *const p这样指针p就完全变为只读的,如;...原创 2019-07-21 14:34:01 · 494 阅读 · 0 评论