Microsoft Interview Question
sizeof is an operator, most probably cannot be implemented in user code. just try your code with sizeof(char), sizeof('c') etc...
ooh don't be so pessimistic...
Since we are not restricted from using RTTI,
can write something like:
works equally well for both types and variables
#define SIZEOF_type(T) \
((char *)((typeof(T) *)0 + 1))
#define sizeof(var) (((int)&(var)+1)-((int)&var))
- mail2vcp@gmail.com September 29, 2008