fork download
  1. #include <iostream>
  2. #include <string.h>
  3. using namespace std;
  4. struct employee
  5. {
  6. int empno, esalary;
  7. string ename;
  8. void set(int number , string name, int salary)
  9. {
  10. this->ename = name;
  11. this->empno = number;
  12. this-> esalary= salary;
  13. }
  14. void print()
  15. {
  16. cout << "employee name : " << ename << endl;
  17. cout << "employee number = " << empno << endl;
  18. cout << "employee salary = " << esalary << endl;
  19. }
  20. void netsal()
  21. {
  22. float w = esalary * 16 / 100;
  23. cout << " salary after deducting 16% = " << w << endl;
  24. }
  25. };
  26. int main()
  27. {
  28. employee r[2];
  29. int number,salary;
  30. string name;
  31.  
  32. for (int i = 0; i < 2; i++)
  33. {
  34. cin>>number>>name>>salary;
  35. r[i].set(number ,name, salary);
  36. }
  37. for (int i = 0; i < 2; i++)
  38. {
  39. r[i].print();
  40. cout<<endl;
  41. }
  42. return 0;
  43. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
employee name : 
employee number = -191029612
employee salary = 5258

employee name : 
employee number = -191029612
employee salary = 5258