Advertisement
Guest User

Untitled

a guest
Aug 29th, 2015
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int f(int x) { return x; }
  4.  
  5. int (&g(int x))[3]
  6. {
  7. static int a[3];
  8. for (int n = 0; n < 3; n++) {
  9. a[n] = x + n;
  10. }
  11. return a;
  12. }
  13.  
  14. int (*h(int x))[3]
  15. {
  16. static int a[3];
  17. for (int n = 0; n < 3; n++) {
  18. a[n] = x + n;
  19. }
  20. return &a;
  21. }
  22.  
  23. class Foo
  24. {
  25. public:
  26. int f(int x) { return x; }
  27. };
  28.  
  29. int main()
  30. {
  31. {
  32. typedef int t0;
  33. t0 n = 0;
  34. }
  35. {
  36. typedef int* t1;
  37. int n = 0;
  38. t1 p = &n;
  39. }
  40. {
  41. typedef int t2(int);
  42. t2 *fp = f;
  43. fp(365);
  44. }
  45. {
  46. typedef (t3)(int);
  47. t3 *fp = f;
  48. fp(365);
  49. }
  50. {
  51. typedef int(*t4)(int);
  52. t4 fp = f;
  53. fp(365);
  54. }
  55. {
  56. typedef int(&t5)(int);
  57. t5 fr = *f;
  58. fr(365);
  59. }
  60. {
  61. typedef int t6[3];
  62. t6 a = {1, 2, 3};
  63. for (auto n : a) {
  64. std::cout << n << std::endl;
  65. }
  66. }
  67. {
  68. typedef int(t7)[3];
  69. t7 a = {1, 2, 3};
  70. for (auto n : a) {
  71. std::cout << n << std::endl;
  72. }
  73. }
  74. {
  75. typedef int(*t8)[3];
  76. int i[] = {1, 2, 3};
  77. t8 a = &i;
  78. for (auto n : *a) {
  79. std::cout << n << std::endl;
  80. }
  81. }
  82. {
  83. typedef int(&t9)[3];
  84. int i[] = {1, 2, 3};
  85. t9 a = i;
  86. for (auto n : a) {
  87. std::cout << n << std::endl;
  88. }
  89. }
  90. {
  91. typedef int(&(*t10)(int))[3];
  92. t10 fp = g;
  93. int (&a)[3] = g(10);
  94. for (auto n : a) {
  95. std::cout << n << std::endl;
  96. }
  97. }
  98. {
  99. typedef int(*(&t11)(int))[3];
  100. t11 fr = *h;
  101. int (*a)[3] = h(10);
  102. for (auto n : *a) {
  103. std::cout << n << std::endl;
  104. }
  105. }
  106. {
  107. typedef int(Foo::*t12)(int);
  108. t12 fp = &Foo::f;
  109. Foo foo;
  110. (foo.*fp)(365);
  111. }
  112. return 0;
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement