代码改变世界

随笔分类 -  C++

calculate the size of the new type

2010-10-02 23:14 by wansishuang, 227 阅读, 收藏,
摘要: You are given have a datatype, say X in C. Determine the size of the datatype,without declaring a variable or a pointer variable of that type, and, of course without usingthe sizeof operator! 阅读全文

assignment operator:对class中const成员变量赋值

2010-09-26 19:19 by wansishuang, 282 阅读, 收藏,
摘要: #include using namespace std; class Test { public: Test(int _a):a(_a) { } Test& operator=(const Test& ra) { if(&ra != this) { const_cast(a) = ra.a; ... 阅读全文