answersLogoWhite

0

#include<iostream.h> #include<conio.h> class complex { int r; int i; public: complex() { } complex(int a,int b) { r=a;i=b; } friend complex operator+(complex,complex); friend show(complex); complex operator+(complex c1,complex c2) { complex c3; c3.r=c1.r+c2.r; c3.i=c1.i+c2.i; return(c3); } show(complex c) { cout<<c.r<<"i+"<<c.i<<endl; } void main() { complex a,b,c; clrscr(); a.complex(3,6); b.complex(4,7); c=a+b; show(a); show(b); show(c); getch() }

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

What is the c plus plus program to calculate the area of a circle using function overloading?

Function overloading is used when you want to re-use the same function name with different argument types or a different number of arguments. Calculating the area of a circle isn't the sort of function that requires overloading since the only argument you need is the radius. double area_of_circle (const double radius) { const double pi=4*atan(1); return pi*radius*radius; }


What is main advantage of using constructors in java?

Constructors have the same name as the class itself and they do not specify a return type, not even void because they return the instance of the class itself. Because constructors have the same name as the class then they allow method overloading and also save memory and execution time of program. Program release memory of constructors function after using this function and it reduce program complexity.


Which function is supported by an application program?

which function is support by an application program


How do you write a java menu driven program using function overloading?

To create a menu-driven program in Java using function overloading, define multiple methods with the same name but different parameters to perform various tasks. For example, you could create overloaded calculate methods that accept different data types (e.g., int, double) for performing calculations. In the main method, present a menu to the user, take their choice as input, and call the appropriate overloaded method based on their selection. This allows for a clean and organized way to handle multiple functionalities with similar operations.


What are its program components?

the main() function,the#include Directive, the variable definition. function prototype, program statements, the function definition,program comments and braces are the components of program in C++


C program to multiply two complex no?

/*C++ program to multiply two complex numbers using * operator overloading*/ #include&lt;iostream.h&gt; #include&lt;conio.h&gt; class complex { float x,y; public: complex() {} complex(float real,float img) { x=real; y=img; } complex operator*(complex); void display() { cout&lt;&lt;x&lt;&lt;" + "&lt;&lt;y&lt;&lt;"i"&lt;&lt;endl; } }; complex complex::operator*(complex e) { complex temp; temp.x=x*e.x+y*e.y*(-1); temp.y=x*e.y+y*e.x; return(temp); } void main() { clrscr(); complex c1(5,3),c2(3,2),c3=c1*c2; c1.display(); c2.display(); cout&lt;&lt;"Multiplication"&lt;&lt;endl; c3.display(); getch(); } OUTPUT: 5 + 3i 3 + 2i Multiplication 9 + 19i


What is a call in programming and how does it function within the context of software development?

In programming, a call refers to invoking a function or method to perform a specific task within a program. When a call is made, the program transfers control to the function being called, executes the code within that function, and then returns control back to the point in the program where the call was made. Calls are essential in software development as they allow for code reusability, organization, and modularization, making it easier to manage and maintain complex programs.


What are the normal results of vision training?

A carefully and individually tailored program of vision therapy should result in a gradual improvement in whatever complex visual function is being addressed.


C program always begins with which function?

That's up to you, but the execution of the program begins with function main.


What is the name of the function which must be defined in a Java program?

The main function. Every program must have a main function and it must be declared static.


Where is the fuction call of main function?

The main function is the entry point into a program. When the Operating System launches the program the main function gets executed.


What is the difference between agent function and agent program in AI?

From what I understand, agent function is a program that maps the percepts to action and update the internal state. an agent program actually implements the agent function