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
Explain the difference between class and struct in c++?
Explain queue. How it can be implemented?
Is c++ platform dependent?
How can you quickly find the number of elements stored in a a) static array b) dynamic array ? Why is it difficult to store linked list in an array?how can you find the nodes with repetetive data in a linked list?
List the advantages of inheritance.
What is istream and ostream in c++?
What is an iterator?
How can I disable the "echo" feature?
What is the most useful programming language?
Are strings immutable in c++?
What is switch case in c++ syntax?
which operator is used for performing an exponential operation a) > b) ^ c) none
Why do we use pointers in c++?
Why is standard template library used?
Reads in the size of a square from the screen; 2. Prints a hollow square of that size out of “-“, “|” and blanks on screen; 3. Prints the same hollow square onto a text file. Your program should work for squares of all side sizes between 1 and 20. --- │ │ │ │ │ │ ---