- 博客(10)
- 问答 (1)
- 收藏
- 关注
原创 TCP/IP 三次握手的代码笔记
//server#include #include #include #include #include using namespace std;char buf[512];int nByte;int main(){ //create socket int fd = 0; if((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
2017-01-17 20:29:07
972
转载 C++改善_2016_11_28
#include using namespace std;//rule04: Make sure that objects are initialized before they're used//确定对象使用前已先被初始化/*对于无任何成员的内置类型,你必须手工完成此事至于内置类型以外的任何其他东西。初始化责任落在构造函数身上。规则很简单:确保每一个构造函数都将对象的每一个成员
2016-11-28 07:29:36
288
转载 C++改善_2016_11_23
//rule03: 尽可能使用const//const,允许你指定一个“不该被改动 ”的对象//编译器会帮你强制实施这个约束//只要这是事实,你就该确实说出来,这样就能获得编译器的帮助,确保这个约束不被违反//在STL中有两种case://1. 声明迭代器为const就像声明指针为const一样,表示这个迭代器不得指向不同的东西,但它所指的东西的值可以改动s
2016-11-24 07:10:08
178
原创 C++顺序表
测试函数://最基本的数据结构之一是线性表/*如下特点:1. 顺序表的内存空间是一连串的地址空间2. 与数据需要一个唯一的数组名一样,顺序表也需要有一个唯一的数组名来表示3. 数据在顺序表中按先后顺序排列,存取是可根据位置随机存取*/#include #include "Seqlist.cpp"using namespace std;int main(){ Seq
2016-11-21 23:21:06
296
转载 C++改善_2016_11_21
Rule 01: 视C++为一个语言联邦: 1. C2. Object-Oriented C++3. Template C++4. STLRule 02: 尽量以const, enum, inline替换 #define//宁可以编译器替换预处理器/*#define ASPECT_RATIO 1.653const double AspectRatio = 1.653;*
2016-11-21 18:39:56
257
转载 程序猿的C++小笔记
1. size_t 只是一个typedef, 是c++计算个数时用的某种不带正负号的(unsigned)类型。它也是vector, deque和string内的operator[ ]函数接受的参数类型。2. explicit 可阻止被用来执行隐式类型转换(implicit type conversions), 但仍可被用来进行显式类型转换(explicit type conversions)
2016-11-14 20:09:58
177
原创 linux学习之<dirent.h>
#include //Linux 下遍历目录的方法,linux下的头文件//打开目录=》读取=》关闭目录//相关函数//opendir=>readdir=>closedir//部分参考源码/*DIR *opendir(const char dirname)struct dirent *readdir(DIR *dp)int close(DIR *dp)struct di
2016-11-08 20:04:55
1204
原创 我的C/C++库理解之memchr
#include #include //原型//void *memchr(const void *str, int c, size_t n)// 搜索参数str指向的字符串的前n个字节中第一次出现的字符c(unsigned char类型)。void *Alex_memchr(const void *str, int c, size_t n);int main(){ const
2016-11-08 07:06:14
1324
原创 我的C/C++库理解之memcpy
#include #include #include #include using namespace std;// void * memcpy ( void * dest, const void * src, size_t num )void * Alex_memcpy(void *dest, const void * src, size_t num);int main
2016-11-03 21:37:54
460
原创 我的C/C++库理解之strrchr
#include #include #include using namespace std;//char * strrchr(const char*, int)//return the last pointer of the char * Alex_strrchr(const char * str, int ch );int main(){ char str[] =
2016-11-03 20:12:48
335
空空如也
为什么加了const就模板函数的具体化编译不过?
2016-12-06
TA创建的收藏夹 TA关注的收藏夹
TA关注的人