Program of function overloading in c++ , C/C++ Programming

Assignment Help:

Program of function overloading:

class vector{

                private :

                int v[3];

 

                public:

                /*friend istream & operator >> (istream & ,vector &);*/ //overloading the

                                                                                                                //insertion operator

                                                                                                                // for the vector type object

                friend vector operator * (vector,int);

                friend vector operator * (int ,vector);

 

                vector()  dummy constructor

                {

                }

       vector (int *p);

 

                 void show();

 

                 }; // class termination

 

                /* istream & operator >>(istrream &din ,vector & b )

                                {

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

                                                din >> b.v[i];

                                  return din;//for cascading

                                }*/

 

 

       vector operator *(vector a,int b)//function overloading

                                {          vector c;

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

                                                                c.v[i]=b*a.v[i];

                                  return c;

                                  }

 

                vector operator *(int a,vector b)

                                {

                                vector c;

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

                                                                c.v[i]=a*b.v[i];

                                  return c;

 

                       }

      vector:: vector( int *p)

      {

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

                                                v[i]=p[i];

 

                }

                void vector ::show()

                {

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

                                                cout << "\n"<

                                 }

 

                void main()

                {

                int t[]={ 1,2,3};

                vector a,b(t),c;

                clrscr();

                a=b*10;

                c=20*b;

                b.show();

                a.show();

                c.show();

                getch();

       }


Related Discussions:- Program of function overloading in c++

Prepare an application in c# or c++, Prepare an Application in C# or C++ ...

Prepare an Application in C# or C++ Project Description: We are seeking someone who can write a program in C# or C++. The idea is to prepare the program using a Cross Plat

Describe how a structure differs from a union, Question : (a) How does...

Question : (a) How does a structure differ from an array? (b) Describe how a structure differs from a union? (c) Declare a union called ‘clothes' which consists of the

Define static storage class - computer programming, Define Static Storage C...

Define Static Storage Class in C Programming? The Static declarations have distinct and important uses. This allows the local variable to keep its previous value when the block

C assignment , 1. Create text a file with the name "myemail" that has a sin...

1. Create text a file with the name "myemail" that has a single line in it, consisting of your email address. Something like "[email protected]" (or your hotmail or gm

Link list, For this program you will add and test 2 new member functions to...

For this program you will add and test 2 new member functions to the IntSLList class posted on the website. The two member functions are: insertByPosn(int el, int pos) Assuming t

Basic data type in cpp, B a s i c D a t a t y p e : ...

B a s i c D a t a t y p e : T h e r e a r e t h r e e t y p e o f d a t a t y p e i n C+ + 1.       P r

Accounts, Write a program to process bank accounts. Create a base class na...

Write a program to process bank accounts. Create a base class named Account and two derived classes named Savings and Checking. In the base class, use an int AccountNum and a dou

Described the difference among "new" and "operator new" ?, Described the di...

Described the difference among "new" and "operator new" ? A:"operator new" works such as malloc.

Please help to solve a c program, Padovan String Problem Description A P...

Padovan String Problem Description A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes s

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd