Question: 1 . Write all programs in cross - platform C + + 2 . No Containers, NO STL allowed { Vector , Lists, Sets, etc...
Write all programs in crossplatform C
No Containers, NO STL allowed Vector Lists, Sets, etc...
Simple Oldfashion C No modern C
No Adding files
Alignment : Identifying data layout and alignment for supplied data structuresC classes
Rework the data structures in ReworkData.h
o Rearrange the data layout to make the size smaller
o Explicitly name any padding in the structure
char pad; for example
Create a Print function to show alignment
o Update the Align::PrintMe function to print the alignment
o Use Trace::out to display the data layout and padding
Make sure you use out and not out
data A:
x:
x: aa aa aa
size : padding :
o Needs to visually show the padding and alignment
Total number of bytes
Number of padding bytes
o Mimic the KeenanSampleOutputDebug.txt
No Templates or Boost allowed
o Use only simple Cclasses and methods
Align.h Do not modify :
#ifndef ALIGNH
#define ALIGNH
class Align
public:
struct Info
int NumTotalBytes;
int NumBytesOfPadding;
;
static Info PrintMEvoid p int StructSize, char s;
;
#endif
End of File
Align.cpp:
#include "Align.h
PrintME
Write your alignment printing function here
Align::Info Align::PrintMEvoid pData int StructSize, char pString
Use Trace::out to display the data layout and padding
NOTE: out NOT out
it won't be graded without out
Mimic the Output
AZULREPLACEMEpData;
AZULREPLACEMEStructSize;
AZULREPLACEMEpString;
Info info;
info.NumBytesOfPadding ;
info.NumTotalBytes ;
return info;
End of File
AlignData.h
#ifndef ALIGNDATAH
#define ALIGNDATAH
Add default constructor to each structure
Initialize all variables to
Do NOT rearrange any data layout...
These are the classes used with Align::PrintMe;
struct A
Hint add the default constructor and set variables to zero
int a;
char a;
;
struct B
float b;
float b;
bool b;
float b;
;
struct C
char c;
double c;
char c;
;
struct D
A d;
double d;
B d;
char d;
C d;
;
struct E
A a;
C c;
char aa;
B b;
;
#endif
End of File
AlignData.cpp:
#include "AlignData.h
Insert code
End of File
ReworkData.h:
#ifndef REWORKDATAH
#define REWORKDATAH
struct DataA
char a;
double r;
char b;
;
struct DataB
int i;
char a;
DataA da;
char b;
;
struct DataC
int j;
char a;
int i;
bool f;
;
struct DataD
int i;
char a;
double r;
char b;
;
struct DataE
char name;
int x;
char a;
double r;
int p;
char c;
;
struct Vect
float vx;
float vy;
char a;
float vz;
float vw;
char b;
;
struct DataF
int i;
Vect v;
char c;
int j;
char b;
;
struct DataG
DataA a;
char b;
double d;
char c;
Vect v;
double d;
;
#endif
End of File
Output like This :
data A:
x:
x: aa aa aa
size : padding :
data B:
x:
x:
x: aa aa aa
xc:
size : padding :
data C:
x: aa aa aa
x: aa aa aa aa
x:
xc:
x: aa aa aa
x: aa aa aa aa
size : padding :
data D:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
