Guest User

Untitled

a guest
Nov 25th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. template<size_t n>
  2. class A
  3. {
  4. int x;
  5.  
  6. public:
  7. void foo() {
  8. A<1> a;
  9. //a.x; // Как получить прямой доступ к x для инстанциаций A<i>, i != 1?
  10. }
  11. };
  12.  
  13. template<size_t n>
  14. class A
  15. {
  16. int x;
  17.  
  18. template<size_t u>
  19. friend class A;
  20.  
  21. public:
  22. void foo() {
  23. A<5> a5;
  24. cout << a5.x;
  25. A<2> a2;
  26. cout << a2.x;
  27. }
  28. };
  29.  
  30.  
  31.  
  32. int main(int argc, const char * argv[])
  33. {
  34. A<8> x;
  35. x.foo();
  36. }
Add Comment
Please, Sign In to add comment