Saturday, 28 January 2012

Program Of Binary Operator (Add two Complex Number) In C++


#include<iostream.h>
#include<conio.h>
class test
{
private:
int a,b;
public:
void getdata(int x,int y)
{
a=x;
b=y;
}
test operator +(test t)
{
test te;
te.a= a + t.a;
te.b= b + t.b;
return te;
}
void display()
{
int c;
cout<<a<<" +  "<<b <<" i";
}

} ;
main()
{
clrscr();
test t1,t2,t3;
t1.getdata(4,5);
t2.getdata(2,7);
t3 = t1 + t2;
t3.display();
getch();
}


------------------------------------------------------------------------------------------


Multiplicative operators: multiplication (*), remainder (%), and division (/) (see Section 6.5.1)


Additive operators: addition (+) and subtraction (-)


Shift operators: left shift (<<) and right shift (>>)


Relational operators: less than (<), less than or equal to (<=), greater than (>), and greater than or equal to (>=)

Equality operators: equality (==) and inequality (!=)

Bitwise operators: AND (&), OR (|), and XOR (^)


Logical operators: AND (&&) and OR (||) 

No comments:

Post a Comment