fork download
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. class student
  5. {
  6. int rol , marks;
  7. char name[20];
  8. public:
  9. student(int r , int m , const char n[])
  10. {
  11. rol = r;
  12. marks = m;
  13. strcpy(name,n);
  14. }
  15. int roll(){return rol;}
  16. };
  17.  
  18. int main()
  19. {
  20. student a[]= {
  21. student(1, 10, "AAA"),
  22. student(2, 20, "BBB"),
  23. student(3, 30, "CCC")
  24. };
  25.  
  26. std::cout << a[0].roll();
  27. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
1