fork download
  1. #include<iostream>
  2. #include<cstring>
  3. using namespace std;
  4. class base{
  5. int a[10];
  6. public:
  7. base(){
  8. for(int i =0;i<10;i++){
  9. a[i]=i;
  10. }
  11. }
  12. int operator[](int n){
  13. return a[n];
  14. }
  15. };
  16. int main (){
  17. base ob;
  18. for(int i =0;i<10;i++){
  19. cout<<ob[i]<<" ";
  20. }
  21. return 0;
  22. }
  23.  
  24.  
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
0 1 2 3 4 5 6 7 8 9