Question: PART 1 ( 2 0 points ) : Compare and contrast the dynamic memory allocation and deallocation operators: new, new [ ] , delete, and

PART 1(20 points):
Compare and contrast the dynamic memory allocation and deallocation operators: new,
new[], delete, and delete[]. Discuss their purposes, differences, and usage scenarios.
PART 2(20 points):
Using the set of files that deal with Complex numbers, you will encounter an error. Identify
the error, explain its cause, and describe how you would resolve the issue.
PART 3(60 points):
Refer to the class COMPLEX from EXAM #2- Complex Files, which facilitates operations
on complex numbers of the form realPart + imaginaryPart * i, where i is
equal to the value of sqrt(-1).
Modify the class to support input and output of complex numbers using the
overloaded >> and operators, respectively. You should remove the toString
function from the class.
Overload the multiplication operator to allow for the multiplication of two complex
numbers, following algebraic principles.
Overload the == and != operators to enable comparisons between complex
numbers.
THE FILES WE WILL WORK ON - HEADER FILE-"// Complex class definition #ifndef COMPLEX_H #define COMPLEX_H # include using namespace std; class Complex { public: Complex(double =0.0, double =0.0);// constructor Complex operator+(const Complex&) const; //addition Complex operator-(const Complex&) const; //subtraction string toString() const; private: double real; // real part double imaginary; // imginary part }; #endif" 2- IMPLEMENTATION FILE -/Complex class member-function definitions. #include #include "Complex.h" using namespace std; //Constructor Complex::Complex(double realPart, double imaginaryPart) : real(realPart), imaginary(imaginaryPart){}//addition operator Complex Complex::operator+(const Complex& operand2) const { return Complex{ real + operand2.real, imaginary + operand2.imaginary }; }//subtraction operator Complex Complex::operator-(const Complex& operand2) const { return Complex{ real - operand2.real, imaginary - operand2.imaginary }; }// retrun string representation of a Complex object in the form: (a, b) string Complex::toString() const { return "("s + to_string(real)+","s + to_string(imaginary)+")"s; } AND LAST MAIN FILE -"# include # include "Complex.h" using namespace std; int main(){ Complex x; Complex y{4.3,8.2}; Complex z{3.3,1.1}; cout "x: " x.toString()"
y: " y.toString()"
z: " z; x = y + z; cout "
x = y + z:
" x.toString()"=" y.toString()"+" z.toString(); x = y - z; cout "
x = y - z:
" x.toString()"=" y.toString()"-" z.toString(); }" i use xcode so rewrite the code according to that only also hints professor gave use - for extra credit - use all three cases using one void pointer i^2, i^3 and i^4) please answer this asap
PART 1 ( 2 0 points ) : Compare and contrast the

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 Programming Questions!