Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- struct Proxy {
- operator int() const { printf("proxy read\n"); return 0; }
- void operator=(int p_value) { printf("equal assign\n"); }
- };
- struct Base {
- const int operator[](int idx) const { printf("const read\n"); return 0; }
- Proxy operator[](int idx) { return Proxy(); }
- };
- int main(int argc,char *argv[]) {
- Base base;
- const int v = (*((const Base*)&base))[1];
- int g = base[1];
- base[1]=2;
- return v;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement