L
Lokicer
hi
I am a newbie in c++, help me!
thanks in much
lokicer
I am a newbie in c++, help me!
thanks in much
lokicer
Michael P. O'Connor said:I believe the reason is because sizeof is a macro instead of a function.
thus this is done in the preprocessor and not in the compiler.
sizeof being a macro..you must be kidding. It's an operator.
hi
I am a newbie in c++, help me!
thanks in much
why sizeof can't be overloaded?
I am a newbie in c++, help me!
thanks in much
2nd: What the heck would you need it for?
Siemel Naran said:2nd: What the heck would you need it for?
One reason: to determine the memory held by the entire object, including
dynamic memory. [...]
Victor Bazarov said:One reason: to determine the memory held by the entire object, including
dynamic memory. [...]
But sizeof is a compile-time operator. How the hell would it report the
dynamic memory? And another sentiment: what would be the use of that
reported size? You can't memcpy it anywhere, you can't pass that size
to the stream::write, because the memory is not contuguous.
Siemel said:Your points are valid. But to many people, especially those not too
familiar with the language, one of the uses of sizeof appears to be to
determine the actual size of an object, which could be useful for
analyzing memory usage of our program.
Siemel said:Victor Bazarov said:One reason: to determine the memory held by the entire object,
including dynamic memory. [...]
But sizeof is a compile-time operator. How the hell would it report
the dynamic memory? And another sentiment: what would be the use of
that reported size? You can't memcpy it anywhere, you can't pass
that size to the stream::write, because the memory is not contuguous.
Your points are valid. But to many people, especially those not too
familiar with the language, one of the uses of sizeof appears to be to
determine the actual size of an object, which could be useful for
analyzing memory usage of our program.
Siemel said:Victor Bazarov said:One reason: to determine the memory held by the entire object,
including dynamic memory. [...]
But sizeof is a compile-time operator. How the hell would it
report the dynamic memory?
Your points are valid. But to many people, especially those not too
familiar with the language, one of the uses of sizeof appears to be to
determine the actual size of an object, which could be useful for analyzing
memory usage of our program.
Old said:Siemel said:Victor Bazarov said:"Siemel Naran" <[email protected]> wrote...One reason: to determine the memory held by the entire object,
including dynamic memory. [...]
But sizeof is a compile-time operator. How the hell would it
report the dynamic memory?
In C99, sizeof can be a run-time operator. And there has been
talk of C++ adopting much of C99.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.