S
Singleton
Can some one guide me what is word boundary?
google is no good for me for this
thanks in advance
google is no good for me for this
thanks in advance
Can some one guide me what is word boundary?
google is no good for me for this
thanks in advance
Singleton said:I just took c++ exam in brainbnch . one of the question is
QAccording to the C++ standard, what is an object's internal
representation in memory guaranteed to be?
Choice 1 : Contiguous
Choice 2 : On the stack
Choice 3 : Initialized
Choice 4 : On a word boundary
Choice 5 : On the heap
Singleton said:Can some one guide me what is word boundary?
google is no good for me for this
thanks in advance
Greg said:The size of an int in a C++ compiler should be the same as the size of
a word for the architecture that that compiler targets.
A word is supposed to be the "natural" size in which the computer
ordinarily processes data. For most computers these days that would be
32 bits. So a word boundary on most machines would occur every four
bytes in memory and start at a byte address evenly divisible by 4.
Greg
John said:On Windows, a WORD is 16 bits on 32 bit machines. A DWORD (double word) is
32 bits.
This may well be because a WORD was 16 bits on earlier 16 bit versions of
Windows and its size has been left at 16 bits for backward compatibility
reasons.
Greg said:Yes, but size of the "int" type in C++ is the one that has to match
the size of a machine word. longs, shorts, and especially typedefs
may or may not match.
In fact the reason that WORD and DWORD exist are to insulate C++
source code from changes in the size of an int. After all, an int is
the type which is the mostly like to change in size. As it did when
the platform moved from 16 to 32 bits, and presumably will again when
it moves from 32 to 64 bits. By using typedefs for integer types, the
programmer can be assured of constant sizes. It allows the programmer
to be able to decide when and how to make the transition to the
larger types, instead of having to do it one day after installing the
latest C++ compiler.
Greg
I just took c++ exam in brainbnch . one of the question is
QAccording to the C++ standard, what is an object's internal
representation in memory guaranteed to be?
Choice 1 : Contiguous
Choice 2 : On the stack
Choice 3 : Initialized
Choice 4 : On a word boundary
Choice 5 : On the heap
I just took c++ exam in brainbnch . one of the question is
QAccording to the C++ standard, what is an object's internal
representation in memory guaranteed to be?
Choice 1 : Contiguous
Choice 2 : On the stack
Choice 3 : Initialized
Choice 4 : On a word boundary
Choice 5 : On the heap
The size of an int in a C++ compiler should be the same as the size of
a word for the architecture that that compiler targets.
Andrew said:Objects with virtual base classes are not always contiguous,
which rules out (1).
The C++ standard requires that the memory for arrays (and vectors)
must be contiguous. This seems to imply that the objects stored
in the array or vector must also use contiguous memory.
What's your definition of 'contiguous' ?
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.