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

Computer Science Engineering C++ Homework, Temperature Conversions. Problem...

Temperature Conversions. Problems 28 through30generate temperature-conversion tables. Use the following equations that give relationships between temperatures in degrees Fahrenheit

Create complex number using constructor , Create Complex number using const...

Create Complex number using constructor: class complex                                 {                                                   private:

C program, program for lexicographically precedes the given input permutati...

program for lexicographically precedes the given input permutation

Pointer declaration for data member, P o i n t e r d e ...

P o i n t e r d e c l a r a t i o n f o r d a t a m e m b e r : M e t h o d 1 : i n t M : : * p x ; / / T h i s

C program for sorting, C Program for SORTING # include stdio.h> void...

C Program for SORTING # include stdio.h> void main() {           char a;           int *p;           int i,j,temp;           clrscr();           p=&i;

Polishing game, Byteland county is very famous for luminous jewels. Luminou...

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

What does extern mean in a function declaration in c++, It tells the compil...

It tells the compiler that a variable or a function exists, even if the compiler hasn't yet seen it in the file presently being compiled. This variable or function may be distinct

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