I. Complex numbers have the form: realPart + imaginaryPart * i where i has the value V-1 A initial class Complex is defi

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

I. Complex numbers have the form: realPart + imaginaryPart * i where i has the value V-1 A initial class Complex is defi

Post by answerhappygod »

I Complex Numbers Have The Form Realpart Imaginarypart I Where I Has The Value V 1 A Initial Class Complex Is Defi 1
I Complex Numbers Have The Form Realpart Imaginarypart I Where I Has The Value V 1 A Initial Class Complex Is Defi 1 (372.04 KiB) Viewed 18 times
I would like some help with these C++ practice questions.
Thanks.
I. Complex numbers have the form: realPart + imaginaryPart * i where i has the value V-1 A initial class Complex is defined for the complex number as follows, the following questions should modify this definition as required. class Complex // (a, d: 20%, others 10 % each) { public: Complex( double , double ); // default constructor Complex add( const Complex & ); // function add Complex subtract( const Complex & ); // function subtract void printComplex(); // print complex number format void setComplexNumber( double, double ); // set complex number private: double realPart; double imaginaryPart; }; // end class Complex a) Implement the constructor that accept two double arguments, e.g. 3.2, 7.5, to initialize the data members by using member-initializer syntax. Make this constructor a default constructor too by assigning the two data members both to values 1.0. The constructor also prints out a message like: Complex number (3.2, 7.5) is constructed. b) Define a destructor that prints a message like: Complex number (3.2, 7.5) is destroyed. c) Define and implement a copy constructor that creates a complex number object and initializes by using another complex number object. d) Implement the other four public functions as the names suggest, i.e. add a complex object to this object, subtract a complex object from this object, print out a complex object as 3.2+7.5i, and set the two data members of a complex object by two double arguments. a) Overload the addition operator (+) as a member function to add another complex number to this complex number object. Make this overloaded function able to perform cascaded operations like: Ca+Cb+Cc. e) Overload the stream insertion operator << and stream extraction operator >> as global functions to print out a complex number as cout << complexObject directly and to input a complex number directly as cin >> complexObject. f) Overload the == and the != operators to allow comparisons of complex numbers. (please use definition of == to define !=) g) Overload the ++ and the -- operators for pre- and post-operations that adds 1 to and minus 1 from both the realPart and the imaginaryPart of a Complex object.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply