Created
October 25, 2013 20:04
-
-
Save dionyziz/7161017 to your computer and use it in GitHub Desktop.
Private access between two different classes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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