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 / ada
I tried sizeof() the class and the output is 40 bytes. I
think the padding maybe like this:
char data1 1+7 bytes
double d 8 bytes
int data2 4 bytes char data3 1+3 bytes
double data4 8 bytes
short data5 2+6 bytes
So totally 5x8=40 bytes
| Is This Answer Correct ? | 3 Yes | 1 No |
Post New Answer View All Answers
Write a program to interchange 2 variables without using the third one.
What are manipulators in c++ with example?
Where can I run c++ program?
What do you mean by storage classes?
What are stacks? Give an example where they are useful.
What is the difference between reference and pointer?
What are the extraction and insertion operators in c++? Explain with examples.
How do you invoke a base member function from a derived class in which you’ve overridden that function?
Define pre-condition and post-condition to a member function in c++?
What are activex and ole?
Where is atoi defined?
Is the declaration of a class its interface or its implementation?
What is a try block?
What c++ library is string in?
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