what is the size of this class
class size
{
public:
char data1;
double d;
int data2;
char data3;
double data4;
short data5;
};

please explain the padding for these double variables.

Answer Posted / nomesh

double will occupies 8 bytes. so here two double data type
variables create then this class size is 21

char 1 b
double 8 b
int 2 b
char 1 b
double 2 b
short 1 b

Is This Answer Correct ?    2 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Do vectors start at 0 c++?

539


What is iostream in c++ used for?

557


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

682


What is the difference between global int and static int declaration?

418


Define token in c++.

731






Who calls main function?

593


What is a terminating character in c++?

785


Can I learn c++ as my first language?

619


Explain the difference between overloading and overriding?

627


What are smart pointers?

682


Explain virtual class and friend class.

614


What are virtual constructors/destructors?

587


what are the iterator and generic algorithms.

1696


What is the maximum value of a unsigned char a) 255 b) 256 c) 128

642


Arrange Doubly linked list in the ascending order of its integral value and replace integer 5 with 7?

3714