Question: Write a program with Old fashion C + + : Deep Copies 1 . Write all programs in cross - platform C + + Optimize
Write a program with Old fashion C : Deep Copies
Write all programs in crossplatform C
Optimize for execution speed and robustness
Working code doesnt mean full credit
No Containers
NO STL allowed Vector Lists, Sets, etc...
o No automatic containers or arrays
o MUST to do this the old fashion way
Simple Oldfashion C
No modern C
o No Lambdas, Autos, templates, etc...
o No Boost
NO Streams
o Used fopen, fread, fwrite...
No code in MACROS
o Code needs to be in cpp files to see and debug it easy
Leaking Memory
If a class creates an object using newmalloc It is responsible for its deletion
Any MEMORY dynamically allocated that isn't freed up is LEAKING.
No Adding files
This project will work asis do not add files.
Fundamentals : Deep Copies
Write a double linked list
o Add to end of list
o Remove any node
o Print the contents of the list
o Deep copy
o Deep assignment
Simple double linked list
o No tail pointers
Car.h:
#ifndef CARH
#define CARH
class Car
public:
add methods
Carconst char pName, int a int b;
Carconst Car &;
Car &operatorconst Car & ;
~Car;
do not add data
Car pNext;
Car pPrev;
const char pName;
int a;
int b;
;
#endif
Garage.h:
#ifndef GARAGEH
#define GARAGEH
#include "Car.h
class Garage
public:
implement these big
Garage;
Garageconst Garage &;
Garage & operator const Garage &;
~Garage;
add methods
do not add data
Car poHead;
;
#endif
main.cpp:
#include "Car.h
#include "Garage.h
int main
Do not change the main function in any way
Trace::out G
;
Car pA new CarA;
Car pB new CarB;
Car pC new CarC;
Garage pG new Garage;
pGAddToEndpA;
pGAddToEndpB;
pGAddToEndpC;
pGPrintpG;
Trace::out Deep Copy: GG
;
Garage pG new GaragepG;
pGPrintpG;
Trace::out G
;
Car pD new CarD;
Car pE new CarE;
Car pF new CarF;
Garage pG new Garage;
pGAddToEndpD;
pGAddToEndpE;
pGAddToEndpF;
pGPrintpG;
Trace::out Deep Assignment G G
;
pGpG;
pGPrintpGpG;
delete pG;
delete pG;
delete pG;
Trace::out
;
Test::RunTests;
output MATCH this sample as close as possible ptrs will be different
Memory Tracking: start
G
GaragepGxBA:
poHead:A
CarAxBD
next: B
prev: null
a:
b:
CarBxBD
next: C
prev: A
a:
b:
CarCxBDA
next: null
prev: B
a:
b:
Deep Copy: GG
GaragepGxBDE:
poHead:A
CarAxBE
next: B
prev: null
a:
b:
CarBxBE
next: C
prev: A
a:
b:
CarCxBE
next: null
prev: B
a:
b:
G
GaragepGxBED:
poHead:D
CarDxBD
next: E
prev: null
a:
b:
CarExBDD
next: F
prev: D
a:
b:
CarFxBDD
next: null
prev: E
a:
b:
Deep Assignment G G
GaragepGpGxBA:
poHead:D
CarDxBDA
next: E
prev: null
a:
b:
CarExBD
next: F
prev: D
a:
b:
CarFxBD
next: null
prev: E
a:
b:
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
