Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

How do you instruct your compiler to print the contents of the intermediate file showing the effects of the preprocessor?

1143


What are single and multiple inheritances in c++?

1095


What is singleton class in c++?

1041


What is a constant reference?

1073


What is setiosflags c++?

967


What is the difference between the functions rand(), random(), srand() and randomize()?

1283


Will rust take over c++?

1054


What is null and void pointer?

1055


Differentiate between structure and class in c++.

1085


What is the difference between passing by reference and passing a reference?

1077


Which recursive sorting technique always makes recursive calls to sort subarrays that are about half size of the original array?

998


What is the word you will use when defining a function in base class to allow this function to be a polimorphic function?

1167


Write a program to find the Fibonacci series recursively.

1071


What is recursion?

2153


What is functions syntax in c++?

1137