A print function that prints the date in the following format of complex numbers such as: a + bi , a – bi
this problem how can i solve
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#ifndef COMPLEXNUMBER_H
#define COMPLEXNUMBER_H
class complexnumber
{
double real_part,imaginary_Part;
public:
complexnumber(double,double);
void Set_Real_Part(double);
double Get_Real_Part();
void Set_Imaginary_part(double);
double Get_Imaginary_part();
void Print();
};
#endif // COMPLEXNUMBER_H
| |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
#include "complexnumber.h"
#include<iostream>
using namespace std;
complexnumber::complexnumber(double RealPart,double ImaginaryPart)
{
real_part = RealPart ;
imaginary_Part = ImaginaryPart ;
}
void complexnumber::Set_Real_Part(double realpart)
{
real_part = realpart;
}
double complexnumber::Get_Real_Part()
{
return real_part;
}
void complexnumber::Set_Imaginary_part(double imaginarypart)
{
imaginary_Part = imaginarypart;
}
double complexnumber::Get_Imaginary_part()
{
return imaginary_Part;
}
void complexnumber::Print()
{
}
| |
i am understand The rest of the question
Create a class ComplexNumber, that includes two data members :
double realPart
double imaginaryPart
The class member functions:
A set and a get declaration/definition for each of the data members of the class complexNumber.
A print function that prints the date in the following format of complex numbers such as: a + bi , a – bi
Parameterized Constructor ComplexNumber (double r, double i);
In the main:
Define the 3 objects from class complexNumber, and initialize its values.
Print the information of the three objects by the member function print.