Untitled
Anonymous
plain_text
03/09/2024 6:12 AM
408 B
18
Indexable
#include <iostream>
using namespace std;
class Int {
public:
int v;
Int(int a) { v = a; }
Int &operator[](int x) {
v += x;
return *this;
}
};
ostream &operator <<(ostream &o, Int &a) {
return o << a.v;
}
int main() {
Int i = 2;
cout << i.v << i[2] << i.v;
return 0;
}
Editor is loading...
Leave a Comment