How to implement sizeof
#define sizeof(var) (int)(&var+1)-(int)&var
#define SIZE1(type) (size_t)((type *)100 + 1) - (size_t)((type *)100)
Int a[2]
Cout<<&a[1]-&a[0]<< endl;//1
Cout<<(int)&a[1]-(int)&a[0]<< endl;//4
Jan 18, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment