Git Cheat Sheet
摘要:source:Git cheat sheethttp://files.cnblogs.com/lbsx/git-cheat-sheet-large.png.zip
阅读全文
posted @
2011-04-19 11:00
lbsx
阅读(460)
推荐(0)
为什么多重继承中需要在"执行期"调整this指针
摘要:这是针对前文的问题的回答。本文强调的是为什么在“执行期”调整,而不是为什么要调整。类层次:1 class A {...}2 3 class B {...}4 5 class C: public A, public B {...}6 7 B* b = new C;8 9 b->foo(); //virtual function在这种情况下,是需要在执行期调整作为参数的this指针的,以例其指向真正的C对象,也就是前文提到的两种方法。为什么编译期不能决定this指针的偏移呢?因为编译期无法确定b指向的真正对象。不需要调整this指针的情况1 B *b = new B;2 3 b->fo
阅读全文
posted @
2011-04-18 16:47
lbsx
阅读(871)
推荐(0)
C++多重继承的多态 - Thunk
摘要:1 class A {...}2 3 class B {...}4 5 class C: public A, public B {...}6 7 B* b = new C;8 9 b->foo(); //virtual function在为line 9实现多态的时候,b指向的不是C对象的开头,而是其subobject B的开头。因此在调用foo时,作为参数的this指针需要被调整,以指向真正的C对象的开始。在《Inside the C++ Object Model》一书中,Lippman提到了两种方案,一种是在虚函数表中不光存放真正调用函数的地址,还存上需要对this指针进行调整的偏移,
阅读全文
posted @
2011-04-18 16:06
lbsx
阅读(1429)
推荐(1)
UTF-8
摘要:http://code.alexreisner.com/articles/character-encoding.html对于以UTF-8编码的字节:if it starts with 0it’s an ASCII characterif it starts with 10it’s a continuation of a multi-byte characterif it starts with 110it’s the first byte of a 2-byte characterif it starts with 1110it’s the first byte of a 3-byte ch
阅读全文
posted @
2011-04-18 15:56
lbsx
阅读(285)
推荐(0)