摘要: 16.5Write a program to find whether a machine is big endian or little endianBig-Endian和Little-Endian的定义如下:1) Little-Endian就是低位字节排放在内存的低地址端,高位字节排放在内存的高地址端。2) Big-Endian就是高位字节排放在内存的低地址端,低位字节排放在内存的高地址端。举一个例子,比如数字0x12 34 56 78在内存中的表示形式为:1)大端模式:低地址 -----------------> 高地址0x12 | 0x34 | 0x56 | 0x782)小... 阅读全文
posted @ 2013-09-10 23:31 冰点猎手 阅读(163) 评论(0) 推荐(0)
摘要: 13.9Write a smart pointer (smart_ptr) classtemplateclass SmartPoint{ public: SmartPoint(T *ref){ ref_ = ref; count_ = (unsigned int *)malloc(sizeof(unsigned int )); *count_ = 1; } SmartPoint(SmartPoint &sptr){ ref_ = sptr.ref_; count_ = sptr.count_; ++(*count_); } SmartPoint& operator =(Smar 阅读全文
posted @ 2013-09-10 21:15 冰点猎手 阅读(225) 评论(0) 推荐(0)