对引用取地址

今天突然想到,如果我们对一个引用取地址,那么会怎么样呢,例如这样 #include <stdio.h> class CNumber { public: int n; }; void printByPointer(CNumber* pNumber) { printf("%d\n", pNumber->n); } void printByRef(CNumber& oNumber) { printf("%d\n", oNumb……

阅读全文

最简 Makefile

依赖于 Makefile 的自动推导,可以写出非常简化的 Makefile,假设目录下有有 Number.cpp 的单个 cpp 文件,内含 main 函数,那么,Makefile 可以这样写 all: Number 是的,就一行,all 作为默认 target,Number 作为依赖,自动推导出依赖源文件 Number.c*,如果是 cpp,得到编译器 g++,如果是 c,得打编译器 cc,然……

阅读全文

练手代码白板

先来一个简单的 list #include <stdio.h> class ListNode { public: ListNode(int n) { this->n = n; this->pNext = NULL; } int n; ListNode* pNext; }; class List { public: ListNode* pHead; List(ListNode* pHead) { this->pHead = pHead; } List* add(ListNod……

阅读全文