摘要: Example 12345678910111213141516171819202122 // vector::data #include <iostream> #include <vector> int main () { std::vector<int> myvector (5); int* p 阅读全文
posted @ 2015-10-07 21:33 PKICA 阅读(11665) 评论(0) 推荐(3)
摘要: void exit(int status){ while(_exit_funcs != NULL) { ... _exit_funcs = _exit_funcs->next; } ... _exit(status);} 其中_exit_funcs是存储由__cxa_atexit和atexit注册的 阅读全文
posted @ 2015-10-01 21:33 PKICA 阅读(291) 评论(0) 推荐(1)
摘要: C++ has from the beginning attempted to improve on the type system of C, adding features like classes that let you build better types and enums, which 阅读全文
posted @ 2015-10-01 11:12 PKICA 阅读(15) 评论(0) 推荐(0)
摘要: 也可参考http://www.cnblogs.com/yc_sunniwell/archive/2010/07/14/1777416.html 对于非内部数据类型的输入参数,应该将“值传递”的方式改为“const 引用传递”,目的是提高效率。例如将void Func(A a) 改为void Func 阅读全文
posted @ 2015-09-27 15:56 PKICA 阅读(23) 评论(0) 推荐(0)
摘要: C++中的struct对C中的struct进行了扩充,它已经不再只是一个包含不同数据类型的数据结构了,它已经获取了太多的功能。struct能包含成员函数、能继承,也能实现多态 struct和class的区别? 最本质的一个区别就是默认的访问控制,体现在两个方面: 1)默认的继承访问权限。struct 阅读全文
posted @ 2015-09-24 19:30 PKICA 阅读(15) 评论(0) 推荐(0)
摘要: register:这个关键字请求编译器尽可能的将变量存在CPU内部寄存器中,而不是通过内存寻址访问,以提高效率。注意是尽可能,不是绝对。你想想,一个CPU 的寄存器也就那么几个或几十个,你要是定义了很多很多register 变量,它累死也可能不能全部把这些变量放入寄存器吧,轮也可能轮不到你。一、皇帝... 阅读全文
posted @ 2015-09-20 22:42 PKICA 阅读(335) 评论(0) 推荐(0)
摘要: int *p()是返回指针的函数 int (*p)()是指向函数的指针 返回指针的函数: int *a(int x,int y); 有若干个学生的成绩(每个学生有4门课程),要求在用户输入学生序号以后,能输出该学生的全部成绩。用指针函数来实现。 1 #include <iostream> 2 #in 阅读全文
posted @ 2015-09-19 21:59 PKICA 阅读(13567) 评论(0) 推荐(1)
摘要: 举例说明: 1)int* p[2] 是一个指向int型的指针数组,即:p是包含两个元素的指针数组,指针指向的是int型。 可以这样来用: 1 #include <iostream> 2 3 using namespace std; 4 5 int main(int argc, char* argv[ 阅读全文
posted @ 2015-09-19 21:43 PKICA 阅读(1511) 评论(0) 推荐(0)
摘要: typedef u_int32_t tcp_seq; struct tcphdr { __extension__ union { struct { u_int16_t th_sport; /* source port */ u_int16_t th_dport; /* destination por 阅读全文
posted @ 2015-09-16 08:09 PKICA 阅读(18) 评论(0) 推荐(0)
摘要: 本文摘自 linux kernel ip.h,感谢开源的GNUstruct ip {#if __BYTE_ORDER == __LITTLE_ENDIAN unsigned int ip_hl:4; /* header length */ unsigned int ip_v:4; ... 阅读全文
posted @ 2015-09-16 07:49 PKICA 阅读(1112) 评论(0) 推荐(0)