fork download
  1. #include <iostream>
  2. using namespace std;
  3. struct Student{
  4. string name;
  5. int age;
  6. float salary;
  7. };
  8. struct Point{};
  9. Student operator+(Student a, Student b) {
  10. Student c;
  11. c.name = a.name + b.name;
  12. c.age = a.age + b.age;
  13. c.salary = a.salary+b.salary;
  14. return c;
  15. }
  16. int main() {
  17. Student x , y , z;
  18. x.name = "Yomna";
  19. x.age = 18;
  20. x.salary = 15.00;
  21. y.name = "Hana";
  22. y.age = 18;
  23. y.salary = 15.00;
  24. z = x + y;
  25. cout << z.name << endl;
  26. cout << z.age << endl;
  27. cout << z.salary << endl;
  28. return 0;
  29. }
Success #stdin #stdout 0.01s 5328KB
stdin
Standard input is empty
stdout
YomnaHana
36
30