随笔分类 - C/C++
摘要:1.sizeof是什么时候编译?返回值类型; 2.函数入栈顺序? 3.位域的优缺点,以及是否具有可移植性; 4.复杂度计算? 5.预编译? 6.断言? 7.可变参数? 8.结构体变量是否可直接赋值使用,是否可以使用==做判断;两个结构体如何做比较?memcmp 9.cmake 10.gdb 手把手教
阅读全文
摘要:#include <stdio.h> #include <stdlib.h> void func(int i) { if (i > 0) { func(i/2); } printf("%d\n", i); } int main() { func(10); return 0; } 输入结果: 0 1
阅读全文
摘要:1.define 1.定义在预编译时处理的宏,只是简单的字符串替换,没有类型检查 2.inline 1.用来定义一个内联函数,引用inline的主要原因是用它替换C语言中表示式形式的宏定义; 2.在编译阶段完成; 3.内联函数会做类型安全检查; 4.内联函数是嵌入式代码,调用内联函数时,不是跳转到内
阅读全文
摘要:#include <stdio.h> #include <stdlib.h> int wei; //未初始化的全局变量,bss区 int you = 0; //初始化为0的全局变量,bss区 int qing = 1; //初始化非0的全局变量,data区 int main() { static i
阅读全文
摘要:编译器优化介绍: 由于内存访问速度远不及CPU处理速度,为提高机器整体性能, 1)在硬件上: 引入硬件高速缓存Cache,加速对内存的访问。另外在现代CPU中指令的执行并不一定严格按照顺序执行,没有相关性的指令可以乱序执行,以充分利用CPU的指令流水线,提高执行速度。 2)软件一级的优化:一种是在编
阅读全文
摘要:1.被extern "C"修饰的变量和函数是按照C语言方式进行编译和链接的:这点很重要!!!! 2.extern "C"包含双重含义 1. 从字面上可以知道,首先,被它修饰的目标是"extern"的; 2. 其次,被它修饰的目标代码是"C"的。 3. 被extern "C"限定的函数或变量是exte
阅读全文
摘要:#include <iostream> #include <string.h> #include <stdio.h> #include <stdlib.h> using namespace std; int main() { int a; //定义一个整数; int *ap; //定义一个指向整数的
阅读全文
摘要:1. scanf函数 scanf()可以接收多种格式的数据,遇到回车,tab,空格时,输入结束; scanf()保留回车符号,当连续两次调用scanf时,会直接读入上一次结束scanf时的回车符号“\n” (0x0a); 没有将回车键屏蔽 #include <iostream> #include <
阅读全文
摘要:#include <iostream> #include "string.h" #include <map> using namespace std; class CTransfer { public: CTransfer(); ~CTransfer(); void statToTrans(cons
阅读全文
摘要:#pragma pack(push, 1) struct test { int a; char b; }; #pragma pack(pop)
阅读全文
摘要:1. 如何判断大小端设备 #include <iostream> using namespace std; typedef union utest { int a; char b; }utest; int main(int argc, char** argv) { utest ut; ut.a =
阅读全文
摘要:http://www.onvif.org/onvif/ver10/device/wsdl/devicemgmt.wsdl http://www.onvif.org/onvif/ver10/event/wsdl/event.wsdl http://www.onvif.org/onvif/ver10/m
阅读全文
摘要:转载:https://blog.csdn.net/vanturman/article/details/80269081 近日,看到这样一行代码: typedef typename __type_traits<T>::has_trivial_destructor trivial_destructor;
阅读全文
摘要:https://blog.csdn.net/luoyayun361/article/details/80428882 #include <iostream> using namespace std; void * func(int a) //指针函数,实质是一个函数,返回值是指针类型; { stat
阅读全文
摘要:https://www.cnblogs.com/eleclsc/p/5918114.html
阅读全文
摘要:当多个数据需要共享内存或者多个数据每次只取其一时,可以利用联合体(union)。在C Programming Language 一书中对于联合体是这么描述的: 1)联合体是一个结构; 2)它的所有成员相对于基地址的偏移量都为0; 3)此结构空间要大到足够容纳最"宽"的成员; 4)其对齐方式要适合其中
阅读全文
摘要:#define _CRT_SECURE_NO_WARNINGS #include #include #include using namespace std; int main(int argc, char * argv[]) { //string str2 = "xiaoliang"; //string str3("xiaohei", 5); //...
阅读全文
摘要:#define _CRT_SECURE_NO_WARNINGS #include #include using namespace std; int main(int argc, char * argv[]) { list lst; lst.push_back(10); //从链表尾部添加 lst.push_front(20); //从链表头部添加 ...
阅读全文
摘要:1.类中重载+操作符 #define _CRT_SECURE_NO_WARNINGS #include <iostream> using namespace std; class Object { public: Object() { } Object(int a) { num = a; } Obj
阅读全文