AbdulFathaah

op over (int * obj) w/o return

Mar 11th, 2024
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include<conio.h>
  2. #include<iostream>
  3. using namespace std;
  4. class vector
  5. {
  6. private :int i,j,k;
  7. public :void read()
  8. {
  9. cout<<"Enter coefficients of i,j,k:";
  10. cin>>i>>j>>k;
  11. }
  12. void display()
  13. {
  14. cout<<i<<"i+ "<<j<<"j+ "<<k<<"k"<<endl;
  15. }
  16. friend void operator*(int x,vector &a)
  17. {
  18. a.i=x*a.i;
  19. a.j=x*a.j;
  20. a.k=x*a.k;
  21. }
  22. };
  23. int main()
  24. {
  25. vector v1;
  26. v1.read();
  27. v1.display();
  28. 4*v1;
  29. v1.display();
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment