Exercise 4: Complex Numbers
Use the class template to define a class that returns the real and imaginary parts of a complex number.
We'll cover the following...
We'll cover the following...
Problem statement
Use class templates to write a template-type class called Complex. This class contains the following properties:
Two
privatevariables are the real and imaginary elements of a complex number.A constructor that takes the real and imaginary parts of a complex number as input and initializes them.
Contains the following two member functions:
get_real(): Returns the real part of the complex number.get_im(): Returns the imaginary part of the complex number.
The code should be generalized; hence should work for any data type.