Aleks11

C++ private "hack"

Jun 16th, 2015
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.23 KB | None | 0 0
  1. class b;
  2.  
  3. class a
  4. {
  5. private:
  6.     a()
  7.     {
  8.     };
  9.  
  10.     friend b;
  11.  
  12.     int aa = 2;
  13. };
  14.  
  15. class b
  16. {
  17. public:
  18.     b()
  19.     {
  20.         c.aa = 2;
  21.     };
  22.  
  23.     int Get()
  24.     {
  25.         return c.aa;
  26.     };
  27.  
  28.     a c;
  29. };
  30.  
  31. int main()
  32. {
  33.     b ss;
  34.     printf("%d\n", ss.Get());
Add Comment
Please, Sign In to add comment