Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<conio.h>
- #include<iostream>
- using namespace std;
- class vector
- {
- private :int i,j,k;
- public :void read()
- {
- cout<<"Enter coefficients of i,j,k:";
- cin>>i>>j>>k;
- }
- void display()
- {
- cout<<i<<"i+ "<<j<<"j+ "<<k<<"k"<<endl;
- }
- friend void operator*(int x,vector &a)
- {
- a.i=x*a.i;
- a.j=x*a.j;
- a.k=x*a.k;
- }
- };
- int main()
- {
- vector v1;
- v1.read();
- v1.display();
- 4*v1;
- v1.display();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment