On 5/28/07, suchismit mahapatra <[EMAIL PROTECTED]> wrote:
> Hi everyone,
> Had a few queries.
>
> Does the concept of "Recursive Macro" exist in C/C++?
No. Macros are evaluated once only.
> It is commonplace knowledge that the smallest object in C++ takes up a
> memory of 1 byte,
Correct.
>depending on compiler preferences.
Incorrect. A conforming compiler will return a unique address for
every 'empty' object. How big that object is, is undefined.
> My query is regarding
> what gets stored in the byte of memory which gets allocated to the object of
> the class.
Nothing. You cannot access that memory. From the C Standard for malloc():
# If the size of the space requested is zero, the behavior is implementation
# defined:
# either a null pointer is returned, or the behavior is as if the size were some
# nonzero value, except that the returned pointer shall not be used to access
# an object.
A class that has zero size, that is included in another class will
have zero size - the 'byte' you're asking about will disappear.
The whole concept is to ensure that, two distinct 'empty' objects will
have unique addresses - to ask what's in that memory makes no sense.
[snip]
> Wanted to know the points on the keyword "volatile" worth knowing.
> Certain types of optimizations are not done on variables which have been
> declared volatile.
> Wanted to know about the optimizations that are generally done on variables.
Generally, if the code does not indicate a change of the value of the
variable, then the compiler assumes it doesn't change. Specifically,
for example, it may not check to see if it has changed before re-using
it some statements later:
for(int i=0; i<10; i++){
// stuff that doesn't change i
}
The compiler may assume that the value of i at the end of the loop
will be the value it had at the start.
--
PJH
"I contend that we are both atheists. I just believe in one fewer god
than you do. When you understand why you dismiss all the other
possible gods, you will understand why I dismiss yours."
-- Stephen Roberts