Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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++?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
361 views
Welcome To Ask or Share your Answers For Others

1 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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...