Skip to content

Instantly share code, notes, and snippets.

@dionyziz
Created October 25, 2013 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dionyziz/7161017 to your computer and use it in GitHub Desktop.
Save dionyziz/7161017 to your computer and use it in GitHub Desktop.
Private access between two different classes.
#include <cstdio>
class Test {
private:
int foo;
public:
Test(int foo_value) {
foo = foo_value;
}
int getFoo(Test* other) {
return other->foo;
}
};
class Toast {
public:
int getFoo(Test* other) {
return other->foo;
}
};
int main() {
Toast* a = new Toast();
Test* b = new Test(10);
printf("%i\n", a->getFoo(b));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment