fork(5) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Foo {
  5. char m_array[64];
  6. char& operator[](size_t index) { return m_array[index]; }
  7. char operator[](size_t index) const { return m_array[index]; }
  8. };
  9.  
  10. int main() {
  11. Foo foo;
  12. foo[0] = 'H';
  13. foo[1] = 'i';
  14. foo[2] = 0;
  15. std::cout << foo[0] << ", " << foo.m_array << '\n';
  16. return 0;
  17. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
H, Hi