Question: 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!
Any help would on this C program would be awesome! Page 9
Page 9 for reference
for reference 2. In C/C++ create the classes myData and myDatal as

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!