
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 · 640 阅读 · 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); }; template T& operator >>(T& instr原创 2016-09-02 21:50:32 · 340 阅读 · 0 评论 -
C++中运算符New的三种使用方式
转自:http://badboywang.iteye.com/blog/446350 1. plain new 普通new [cpp] view plain copy void*operator new(std::size_t)throw(std::bad_alloc); void operator delete( void *) thro转载 2016-10-11 23:32:58 · 1053 阅读 · 0 评论 -
【转】一个C语言宏展开问题
转自 http://www.cnblogs.com/9sheng/archive/2011/03/22/2684247.html 一个令人比较迷惑的问题,学C语言好多年,今天终于搞明白,记之。 1 #define cat(x,y) x ## y 2 #define xcat(x,y) cat(x,y) 3 cat(cat(1,2),3) //为什么不是 123? 4 xcat(x转载 2016-11-03 10:51:47 · 747 阅读 · 0 评论 -
C++数据类型
数据类型原创 2016-10-06 20:21:18 · 232 阅读 · 0 评论 -
【转】 OO七大原则
转自http://blog.youkuaiyun.com/ql15010832315/article/details/53127724 OO七大原则为:单一职责原则、开闭原则、里氏替换原则、依赖倒置原则、接口隔离原则、合成/聚合复用原则、迪米特法则 1、单一职责原则SRP(Simple Responsibility Principle): 单一职责原则,就是一个设计元素只做一件事。什么是转载 2016-11-11 19:01:55 · 333 阅读 · 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 · 489 阅读 · 0 评论