![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c++
gitprx
这个作者很懒,什么都没留下…
展开
-
函数指针作为模板函数的非模板参数
template int search(T* pt, int size, T t, bool(*f)(T t1, T t2)){ for (int i = 0; i != size; ++i) { if (f(t, pt[i])) return i; } return size;}上面的search目的是在T类型的数组中按照f方法查找元素t原创 2016-08-30 13:22:18 · 599 阅读 · 2 评论 -
c++中定制输入输出操作
用模板重载友元操作符即可直接代码class test{ int out=0; int in; template friend T& operator >>(T& instream, test t); template friend T& operator <<(T& outstream, test t);};templateT& operator >>(T& instr原创 2016-09-02 21:50:32 · 303 阅读 · 0 评论 -
C++中运算符New的三种使用方式
转自:http://badboywang.iteye.com/blog/4463501. plain new 普通new[cpp] view plain copyvoid*operator new(std::size_t)throw(std::bad_alloc); void operator delete( void *) thro转载 2016-10-11 23:32:58 · 1005 阅读 · 0 评论 -
【转】一个C语言宏展开问题
转自 http://www.cnblogs.com/9sheng/archive/2011/03/22/2684247.html一个令人比较迷惑的问题,学C语言好多年,今天终于搞明白,记之。1 #define cat(x,y) x ## y2 #define xcat(x,y) cat(x,y)3 cat(cat(1,2),3) //为什么不是 123?4 xcat(x转载 2016-11-03 10:51:47 · 684 阅读 · 0 评论 -
C++数据类型
数据类型原创 2016-10-06 20:21:18 · 199 阅读 · 0 评论 -
【转】 OO七大原则
转自http://blog.csdn.net/ql15010832315/article/details/53127724OO七大原则为:单一职责原则、开闭原则、里氏替换原则、依赖倒置原则、接口隔离原则、合成/聚合复用原则、迪米特法则1、单一职责原则SRP(Simple Responsibility Principle):单一职责原则,就是一个设计元素只做一件事。什么是转载 2016-11-11 19:01:55 · 287 阅读 · 0 评论 -
刑侦推理暴力解法c++版
#include<iostream>#include<cmath>#include<vector>using namespace std;int an[10] = { 0 };bool isnb(int a, int b){ return (a - b == -1) || (a - b == 1);}void print(){ for...原创 2018-03-05 01:27:28 · 409 阅读 · 0 评论