Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Any help would on this C program would be awesome! Page 9 for reference 2. In C/C++ create the classes myData and myDatal as shown

Any help would on this C program would be awesome!
image text in transcribed
Page 9 for reference
image text in transcribed
2. In C/C++ create the classes myData and myDatal as shown at top of page 9 and in the example below. #include class myData { short int height; long int haircount; long int numFreckles; short int weight; }; class myDatal { short int height; short int weight; long int hairCount; long int numFreckles; Use a main program like the one shown below to verify the actual size of the two classes. void main(void) printf("size of myDatao in bytes = %d ", sizeof(myData()); printf("size of mybatao in bytes = %d ", sizeof(mypatal)); } Figure 1.2. Two classes with same data content, but because the data is arranged differently, the class sizes will be different. This effect is caused by word alignment, Memory Map for class: myDatao 0 8 height hairCount 0 1 2 3 4 5 6 7 8 12 16 numFreckles weight 8 9 10 12 13 14 15 Figure 1.3. Data map for the myData) class. The yellow block represent bytes that hold data. The light blue bytes represent bytes that are not used because the computer wants to start word length data items on a word boundary. Class size is 16 bytes Memory Map for class: myDatal 8 height weight hairCount 0 1 2 3 4 5 7 numFreckles 12 16 00 9 10 11 12 13 14 15 Figure 4. This figure illustrates how rearranging of the data in the class can save 4 bytes. Here the class size is 12 bytes versus 16 for the myDots class as shown in figure 3. Once again yellow blocks represent bytes that are used by the class, blue blocks represent blocks not used by the structure the heavy vertical lines represent word boundaries

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions