fork download
  1. #include <iostream>
  2. using namespace std; // consider removing this line in serious projects
  3. class M
  4. {
  5. public:
  6. M(int i,int j)
  7. {
  8. m1=i;
  9. m2=j;
  10. }
  11. void Sum(M a,M b)
  12. {
  13. m1=a.m1+b.m1;
  14. m2=a.m2+b.m2;
  15. }
  16. void print()
  17. {
  18. cout<<"m1="<<m1<<",m2="<<endl;
  19. }
  20. private:
  21. int m1,m2;
  22. };
  23. int main()
  24. {
  25. M a(34,78);
  26. M b(a);
  27. M c(a);
  28. c.Sum(a,b);
  29. c.print();
  30. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
m1=68,m2=