Facebook
From RONO, 9 Years ago, written in C++.
Embed
Download Paste or View Raw
Hits: 646
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. template <class typ>
  6. class Moja
  7. {
  8.     public:
  9.         void fun();
  10.         void fun_2();
  11. };
  12.  
  13. template <class typ>
  14. void Moja<typ>::fun()
  15. {
  16.     cout << "Standardowa funkcja" << endl;
  17. };
  18. template <class typ>
  19. void Moja<typ>::fun_2()
  20. {
  21.     cout << "Standardowa funkcja nr. 2" << endl;
  22. };
  23.  
  24. template <>
  25. void Moja<char>::fun()
  26. {
  27.     cout << "Funkcja do typu char" << endl;
  28. };
  29.  
  30. int main()
  31. {
  32.     Moja<int> test;
  33.     Moja<char> test_2;
  34.     test.fun();
  35.     test_2.fun();
  36.    
  37.     test.fun_2();
  38.     test_2.fun_2();
  39.    
  40.     return 0;
  41. }