whats the size of class EXP on 32 bit processor?
class EXP
{
char c1;
char c2;
int i1;
int i2;
char *ptr;
static int mem;
};
Answer Posted / ricardo
The answer is 16 (on most compilers), but not for the
reasons stated above.
If the class contained only c1 and c2, the size would be
2. Since i1 is an integer, though, it needs to be aligned
on a 4-byte multiple. The pointer and the other integer
also uses up 4 bytes. So, the total size is 16.
If there were another character field "c3" adjacent to c2,
the size would still be 16 bytes.
Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
What is endl c++?
What is function overloading in C++?
Why main function is special in c++?
What is atoi?
Are strings mutable in c++?
Write bites in Turbo c++ Header ("Include") Files.
What is abstraction with real time example?
Why pointer is used in c++?
Explain how functions are classified in C++ ?
Explain what is class definition in c++ ?
What is a down cast?
How would you find out if a linked-list is a cycle or not?
Why do we use templates?
Explain the concept of friend function in c++?
What should main() return in c and c++?