03 2021 档案
摘要:class CSub2 { public: CSub2() { cout << "默认构造函数:" << this <<endl; } CSub2(int x) : m_x(x) { cout << "构造函数:" << m_x << ":" << this << endl; } CSub2& op
阅读全文
摘要:https://blog.csdn.net/wudishine/article/details/12307611
阅读全文
摘要:template<typename T> void funcTmp(T a, T b) { cout << "this is yiban" << endl; } template<> void funcTmp(const char* a, const char* b) { cout << "this
阅读全文
摘要:1. 必须使用初始化列表初始化一个引用成员; class CBase { public: CBase(int a) : m_a(a) //正确,m_a是一个变量的引用,必须通过初始化列表初始化 { // m_a = a; //错误 cout << "m_a:" << m_a << endl; } p
阅读全文
摘要:https://chenqx.github.io/2014/09/25/Cpp-Memory-Management/
阅读全文
摘要:1. static_cast用法:static_cast < type-id > ( exdivssion ) 该运算符把exdivssion转换为type-id类型,但没有运行时类型检查来保证转换的安全性。它主要有如下几种用法:① 用于类层次结构中基类和子类之间指针或引用的转换。 进行上行转换(把
阅读全文
摘要:什么是顶层和底层const: 1. 顶层const:指const定义的变量本身是一个常量; 2. 底层const:指const定义的变量所指向的对象是一个常量; const int i = 0; //顶层const,变量i就是常量; const int * a = &i; //底层const, a所
阅读全文
摘要:class tmp { public: int a; int b; }; class ctest { public: ctest() { p = new tmp; } ~ctest() { delete p; } ctest& operator = (const ctest& t) { tmp *
阅读全文
摘要:int search(vector<int>& nums, int target) { int left = 0; int right = nums.size(); if (right == 0) { return -1; } bool flag = false; while (left<right
阅读全文
摘要:1.final 当希望类不被继承或者虚函数不被重写时,可以在类名后面或者函数后面使用final修改; 2.override 当表明此函数是重写而来时,可以用override修饰,此时编译器会检查是否为重写的函数;
阅读全文
摘要:Node* reveser(Node *head) { if (head == NULL) { return NULL; } Node* pre = NULL; Node* next = NULL; while (head != NULL) { next = head->next; head->ne
阅读全文
摘要:bool checkArr(char * arr, int len, int* max) { if (NULL == arr || len == 0 || max == NULL) { return false; } int maxdepth = 0, deep = 0; for (int i =
阅读全文
摘要:bool testFunc(int k) { char kai[] = { 1, 2, 1, 3, 4, 5, 1 }; int size = sizeof(kai); for (int i = 0; i < size; i++) { for (int j = 1; j <= k; j++) { i
阅读全文
摘要:ListNode* ReverseList(ListNode* head, ListNode* tail) { ListNode* pre = NULL; ListNode* next = NULL; while (head != tail) { next = head->next; head->n
阅读全文
摘要:int main(){ int arr[] = {4,2,3,5,6}; int n = sizeof(arr) / sizeof(int); int t = 0; for (int i = 1; i <= n+1; i++) { t ^= i; } for (int i = 0; i < n; i
阅读全文
摘要:ListNode* ReverseList(ListNode* pHead) { if (pHead == NULL) { return NULL; } ListNode pHeadNew(0); pHeadNew.next = pHead; ListNode* curNode = pHead; L
阅读全文
摘要:https://www.cnblogs.com/ooo0/p/12161786.html 值得一再强调的是,空间复杂度是根据额外需要的内存空间(也叫辅助空间)来算的,也就是说原本的数据不纳入计算。 尽管在第二个版本里我们有array这一入参,占用了N个元素的空间,但除此之外它并没有消耗额外的内存,所
阅读全文
摘要:__attribute__((constructor)) void before() { printf("this is main before\n"); } __attribute__((destructor)) void after() { printf("this is main after\
阅读全文
摘要:#pragma pack(6)struct test{ char f[10]; //自身对齐值是1,指定对齐值是6,有效对齐值1 //f首地址0x0, 所在内存空间0x0-0x09 double z; //自身对齐值是8,指定对齐值是6,有效对齐值6 //z的首地址需要被有效值6整除,但是0x09之
阅读全文
摘要:int main(){ int arr[] = { 1, 2, 3, 4, 6, 7,6 }; int hashTable[10000] = { 0, }; int start = 0; int max = 1; int size = sizeof(arr); for (int i = 0; i <
阅读全文
摘要:1. 启动init进程2. 读取inittab配置表 myttyS0: :respawn : /etc/init.d/appauto label : runlevel :action : process respawn: 如果process字段指定的进程不存在,则启动该进程,init不等待处理结束,
阅读全文