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

Explain pure virtual functions, Pure Virtual Functions An abstract clas...

Pure Virtual Functions An abstract class is one, which is used just for deriving some other classes. No object of this class is declared and used in the program. Likewise, ther

Prime no., program to find if a no . is prime or not

program to find if a no . is prime or not

Default value functions, Default Value Functions,  When declaring a functio...

Default Value Functions,  When declaring a function we can specify a default value for each parameter. This value will be used if that parameter is left blank when calling to the f

201 it, overloadstream insertion opertator to display the data of object on...

overloadstream insertion opertator to display the data of object on the console

How do you connect a c++ program to c functions?, A: Using the extern "C" l...

A: Using the extern "C" linkage specification around the C function declarations. Programmers must know about mangled function names and type-safe linkages. After that they must

Lexicographically preceding permutation, Respected Sir, I want the above wr...

Respected Sir, I want the above written text in a C program

What is an incomplete type in c++, Incomplete types refer to pointers in wh...

Incomplete types refer to pointers in which there is no availability of the execution of the referenced location or it points to some location whose value is not available for modi

Program to store family members details, Program to store family members de...

Program to store family members details in C++: #include #include #include struct record {   char name[30];   int age;   char state[40]; }x; //cal

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