Program of cascading, C/C++ Programming

Assignment Help:

Program of cascading:

class vector{

                private :

                int v[3];

 

                public:

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

                                                                                                                //insertion operator

                                                                                                                // for the vector type object

                friend ostream & operator << (ostream & ,vector &);

                friend vector operator * (vector,int);

                friend vector operator * (int ,vector);

 

                void show();

 

                 }; // class termination

 

                 istream & operator >>(istream &din ,vector & b )

                                {

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

                                                {

                                                cout<<"enter "<

                                                din >> b.v[i];

                                                }

                                  return din;//for cascading

                                }

                   ostream & operator <<(ostream &dout ,vector & b )

                                {

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

                                                {

                                                dout << b.v[i]<<"\n";

                                                }

                                  return dout; //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;

 

                       }

                void vector ::show()

                {

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

                                                cout << "\n"<

                                 }

 

                void main()

                {

                vector a,b,c;

                clrscr();

 

                cin>>b;//calling function cin is 1st argument and b other

                cout << b;

                a=b*10;

                c=20*b;

/*           b.show();

                a.show();

                c.show();*/

                cout<

                cout<

                getch();

       }


Related Discussions:- Program of cascading

Private member functions, P r i va t e Member Functions: A private...

P r i va t e Member Functions: A private member functions can be called by the members of the same class.  Consider the following example.   c l a ss sample

Can i drop the [] while deleteing array of some built-in , Can I drop the [...

Can I drop the [] while deleteing array of some built-in type (char, int, etc)? A: No. you can't Sometimes programmers think that the [] in the delete[] p only present so the

Compiler design limiting instruction, Ravi is a newbie to the programming a...

Ravi is a newbie to the programming and while learning the programming language he came to know the following rules: · Each program must start with ''''{'''' and end with ''''}

Problem : Change to palindrome, A palindrome is a string that reads the sam...

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

Memory management system, 1. Basic Heap: Each memory location in our model ...

1. Basic Heap: Each memory location in our model of the RAM will be an instance of type Memory: 2. typedef union Memory_u Memory; 3. union Memory_u{ 4. char character;

Project of result management system in c language, how we write decision ta...

how we write decision tables, flowcharts,pseudocode,and algorithm in result management system

Pascal programming , 1. The management of a company would like to determine...

1. The management of a company would like to determine the median annual salary of its employees.Write a pascal program that display the number of employees and their median salary

Is probable to encompass virtual constructor? if yes, Is it probable to enc...

Is it probable to encompass Virtual Constructor? If yes, how? If not, Why?

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