fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class department
  5. {
  6. public:
  7. int id;
  8.  
  9. static void max(department *depts, int count)
  10. {
  11. for(int i = 0; i < count; ++i) {
  12. cout << "depts[" << i << "].id = " << depts[i].id << endl;
  13. }
  14. }
  15. };
  16.  
  17. class B : public department {
  18. };
  19.  
  20. int main()
  21. {
  22. B a[10];
  23. for(int i = 0; i < 10; ++i) {
  24. a[i].id = i+1;
  25. }
  26.  
  27. department::max(a, 10);
  28. return 0;
  29. }
Success #stdin #stdout 0s 5508KB
stdin
Standard input is empty
stdout
depts[0].id = 1
depts[1].id = 2
depts[2].id = 3
depts[3].id = 4
depts[4].id = 5
depts[5].id = 6
depts[6].id = 7
depts[7].id = 8
depts[8].id = 9
depts[9].id = 10