Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class bar
- {
- public:
- bar(int* z)
- {
- ptr = z;
- }
- int* ptr;
- void change()
- {
- *ptr = *ptr + 1;
- }
- };
- class foo
- {
- public:
- int x;
- bar* b;
- foo()
- {
- x=10;
- b = new bar(&x);
- }
- };
- int main()
- {
- foo a;
- (a.b)->change();
- printf("%d\n",a.x);
- return 0;
- }
Add Comment
Please, Sign In to add comment