assignment 4

Upload: nida-butt

Post on 02-Mar-2016

217 views

Category:

Documents


0 download

DESCRIPTION

assignment

TRANSCRIPT

Assignment # 41. Declare a class Number that contains two data member value1 and value2 of the type of integer, define constructor to give initial value, and perform addition , subtraction, multiplication and division on two objects of this class let say n1,n2 using operating overloading of +,-,*,/ operator respectively [hint- binary operator overloading using member function]2. Declare a class Number1 that contains two data member value1 and value2 of the type of integer, define constructor to give initial value, and perform addition, subtraction, multiplication and division on two objects of this class let say n1,n2 using operating overloading of +,-,*,/ operator respectively [hint- binary operator overloading using friend function]3. Declare a class Number2 that contains a data member value of the type of integer, define constructor to give initial value, and perform unary minus, increment and decrement object of this class using operating overloading of -,++,-- operator respectively [hint- Unary operator overloading using member function]4. Declare a class Number3 that contains a data member value of the type of integer, define constructor to give initial value, and perform unary minus, increment and decrement object of this class using operating overloading of -,++,-- operator respectively [hint- Unary operator overloading using friend function]5. Declare a class Number4 that contains a data member value of the type of integer, define constructor to give initial value, and find greater between two objects of this class let say n1, n2 using friend function.6. Write a program in C++ to display students information using friend function.7. Declare a class Number4 that contains a data member value of the type of integer, define constructor to give initial value, and swap between two objects of this class let say n1, n2 using friend function.8. MATRIX OPERATION USING OPERATOR OVERLOADING

AimTo create a C++ program for performing matrix operations using operator overloading.

Algorithm

Step 1: Create 3 object for the matrix class m1, m2, m3.

Step 2: Read the elements of the matrix A and matrix B using the getdata function in the matrix class, which is invoked by the object m1 and m2.Step 3: Invoked the operator function for matrix addition using the

statement m3=m1.operator+(m2). Step 4: Create an object c of the type matrix.Step 5: Calculate matrix addition of the matrices of m1 and m2 and Store it in the object c return c.

Step 6: Display the resultant matrix using the display member

Function of matrix by invoking through the object m3.

Step 7: Call the operator function for matrix subtraction using the

Statement m3=m1-m2.

Step 8: Pass the object m1 and m2 to the operator function. Step 9: Create an m3 object of type matrix.Step 10: Calculate matrix subtraction using the object m1 and m2 and store in the object m3 created.Step 11: Invoke the display function using the object m3.

Step 12: Call the operator function for matrix multiplication using the statement m3=m1*m2.Step 13: Create an object of type matrix.

Step 14: Perform the matrix multiplication and store it in the object and return it. Step 15: Invoke the display function using the object m3.