C program to show overloading of matrix operator, C/C++ Programming

C program to show overloading of matrix operator:

Write a program for matrix operator overloading.

class matrix{


                private :

                int x[2][2];



                void show();


                matrix operator + (matrix);

                matrix(int a,int b,int c,int d);//consructor


                matrix() //default constructor


                for (int i= 0;i<2;i++)

                for(int j=0;j<2;j++)







                 void matrix ::show()


                 for (int i= 0;i<2;i++)

                                for(int j=0;j<2;j++)

                                                 cout <<"\n"<



                  matrix:: matrix (int a,int b,int c,int d)//constructor definition










                 matrix   matrix :: operator +(matrix b)


                    matrix c;

                    for (int i= 0;i<2;i++)

                                for(int j=0;j<2;j++)

                                    c.x[i][j]=x[i][j] + b.x[i][j];

                     return c;



       void main()


                  matrix a,b,c;



                  c=a+b; //c=a.operator + (b);

                                 //here b is the argument passed to the memeber function

                                 //where a is the invoking object of the operator + function

                                 //whereas in friend function a anb b are treated as





Posted Date: 10/19/2012 2:59:53 AM | Location : United States

Related Discussions:- C program to show overloading of matrix operator, Assignment Help, Ask Question on C program to show overloading of matrix operator, Get Answer, Expert's Help, C program to show overloading of matrix operator Discussions

Write discussion on C program to show overloading of matrix operator
Your posts are moderated
Related Questions
This assignment builds on Homework 3. The two major modifications are the instruction of pointers and the calculation of mortgage interest rates. Requirements for Project 2:

Ask questionByteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular

Develop a Motion sensor in Altera control Project Description: I want a project written in c using Altera eclipse development tool, that controls a motion sensor ( SRF05 ) fr

In this we will take a closer look at the logic behind Object Oriented Programming.  Read through the pseudocode listed below and answer the following questions. Class Square

After p = new Fred[n], how does the compiler know about n objects to be destructed throughout delete[] p? A:  The run-time system hold the number of objects, n, somewhere where

C Program for FUNCTION  OF COMPOUND INTEREST float ci(float,float,float); void main() {           float p=0,r=0,n=0,k=0;           clrscr();           printf("EN

Write a Haskell program that calculates a balanced partition of N items where each item has a value between 0 and K such that the difference between the sum of the values of first

C Program for REVERSE THE STRING #include stdio.h> #include conio.h> #include string.h> void main() {           char name[30];           char *s;

The Switch Construct The switch statement is a multi-way decision-making construct that tests an expression matches one of a number of constant values, and branches accordingly

depth description of the inside and outside typecasting