Advertisement
Guest User

Edward

a guest
Nov 30th, 2015
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.10 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. ////////////////////////////////////////////////
  6. //C помощью перегруженных функций(без классов)//
  7. ////////////////////////////////////////////////
  8.  
  9. //void mas1(char * mas)
  10. //{
  11. //      for (int i = 0; i < 10; i++){
  12. //              cout << mas[i];
  13. //      }
  14. //}
  15. //void mas1(int * mas)
  16. //{
  17. //      for (int i = 0; i < 10; i++)
  18. //{
  19. //              mas[i] = i;
  20. //              cout << mas[i];
  21. //      }
  22. //}
  23. //
  24. //int main()
  25. //{
  26. //      char a[10] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'k', 'l', 'm' };
  27. //      int b[10] = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' };
  28. //      cout << "Character Array" << endl;
  29. //      mas1(a);
  30. //      cout << endl << endl;
  31. //      cout << "Number Array" << endl;
  32. //      mas1(b);
  33. //      return 0;
  34. //}
  35.  
  36.  
  37. ////////////////////////////////////////////////////////////
  38. //С помощью перегруженных конструкторов или методов класса//
  39. ////////////////////////////////////////////////////////////
  40.  
  41. //class A
  42. //{
  43. //public:
  44. //      void mas1(char * mas)
  45. //      {
  46. //              for (int i = 0; i < 10; i++)
  47. //              {
  48. //                      cout << mas[i];
  49. //              }
  50. //      }
  51. //      void mas1(int * mas)
  52. //      {
  53. //              for (int i = 0; i < 10; i++)
  54. //              {
  55. //                      mas[i] = i;
  56. //                      cout << mas[i];
  57. //              }
  58. //      }
  59. //};
  60. //
  61. //int main()
  62. //{
  63. //      A obj;
  64. //      char a[10] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'k', 'l', 'm' };
  65. //      int b[10] = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' };
  66. //      cout << "Character Array" << endl;
  67. //      obj.mas1(a);
  68. //      cout << endl << endl;
  69. //      cout << "Number Array" << endl;
  70. //      obj.mas1(b);
  71. //      return 0;
  72. //}
  73.  
  74.  
  75. ////////////////////////////////
  76. //С помощью обобщенных функций//
  77. ////////////////////////////////
  78.  
  79. //template<class A> void mas1(A * mas)
  80. //{
  81. //      for (int i = 0; i < 10; i++)
  82. //      {
  83. //              cout << mas[i];
  84. //      }
  85. //}
  86. //
  87. //int main()
  88. //{
  89. //      char a[10] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'k', 'l', 'm' };
  90. //      int b[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
  91. //      cout << "Character Array" << endl;
  92. //      mas1(a);
  93. //      cout << endl << endl;
  94. //      cout << "Number Array" << endl;
  95. //      mas1(b);
  96. //      return 0;
  97. //}
  98.  
  99.  
  100. //////////////////////
  101. //С помощью шаблонов//
  102. //////////////////////
  103.  
  104. //template<class A> class mas1
  105. //{
  106. //public:
  107. //      mas1(A * mas)
  108. //      {
  109. //              for (int i = 0; i < 10; i++)
  110. //              {
  111. //                      cout << mas[i];
  112. //              }
  113. //      }
  114. //};
  115. //
  116. //int main()
  117. //{
  118. //      char a[10] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'k', 'l', 'm' };
  119. //      int b[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
  120. //      cout << "Charater Array" << endl;
  121. //      mas1<char> ob1(a);
  122. //      cout << endl << endl;
  123. //      cout << "Number Array" << endl;
  124. //      mas1<int> ob2(b);
  125. //      return 0;
  126. //}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement