I am confused about the evaluation time of sizeof
operator.
When does the sizeof operator get evaluated?
Does its evaluation time (compile-time or runtime) depend on the language (C? C++?)?
Can we use sizeof
in case of objects created at runtime in C++?
Best Answer
In almost all cases,
sizeof
is evaluated based on static type information (at compile-time, basically).One exception (the only one, I think) is in the case of C99's variable-length arrays (VLAs).