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 / kanthi

I have a small doubt.. isnt it based upon the underlying
platform on which this piece of code is run?
as far as my c++ knowledge goes, the size of each datatype
varies for each platform unlike java. this is the reason
why java ensures portability of code, while c++ doesnt.
please tell me if i am wrong...

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is iostream in c++ used for?

549


How are virtual functions implemented in c++?

596


Explain how overloading takes place in c++?

568


Define vptr.

594


True or false, if you keep incrementing a variable, it will become negative a) True b) False c) It depends

1853






What is a terminating character in c++?

760


What are pointers, when declared, intialized to a) NULL b) Newly allocated memory c) Nothing. Its random

647


What is the role of copy constructor in copying of thrown objects?

593


What is vector string in c++?

570


What is a manipulator in c++?

711


Ask to write virtual base class code?

2147


Must accepts "Maestro Cards" Tax for bike should be less than 15 Total number of lanes is more than 10 Must provides monthly pass Write a method: boolean isGoodTollBridge(String[] cardsAccepted, String[] tollTax, boolean hasMonthlyPass, int numberOfLanes); String[] cardsAccepted A String array of names of card types accepted for payment of toll tax, it can be null if the toll does not accept any card String[] tollTax A String array of toll tax chart (say “Train : 300”,”BullCart : 10”) boolean hasMonthlyPass This parameter defines whether there is any monthly pass available or not int numberOfLanes This parameter defines the number of lanes for each side

3044


Refer to a name of class or function that is defined within a namespace?

598


How are the features of c++ different from c?

589


How would you call C functions from C++ and vice versa?

634