Answer to Question #227383 in C++ for ajay

Question #227383
Write base class that ask the user to enter Time (hour minute and second) and derived class adds the Time of its own with the base. Finally make third class that is friend of derived and calculate the difference of base class time and its own time.
1
Expert's answer
2021-08-19T03:21:53-0400
#include<iostream.h>
#include<conio.h>
class complex
{
   private:
	float x;
	float y;
   public:
	void set(float real, float img)
	{
		x=real; y=img;
	}
	complex sum(complex);
	void disp();
};
complex complex::sum(complex C)
{
	complex t;
	t.x = x + C.x;
	t.y = y + C.y;
	return t;
}
void complex::disp()
{
	cout<<x<<" + j"<<y<<endl;
}
int main()
{
	complex C1,C2,C3;
	C1.set(2.5,7.1);
	C2.set(4.2,5.5);
	C3=C1.sum(C2);
	cout<<"\n complex Number 1 = ";C1.disp();
	cout<<"\n complex Number 2 = ";C2.disp();
	cout<<"\n complex Number 3 = ";C3.disp();
	getch();
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS