Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. template <class T>
  2. class Set
  3. {
  4. public:
  5. T ch;
  6. set <T> cs; //создаем множество
  7.  
  8. Set()
  9. {
  10. int n;
  11. T temp;
  12. cout << "Количество элементов множества";
  13. cin >> n;
  14. for (int i = 0; i < n; i++)
  15. {
  16. cin >> temp;
  17. cs.insert(temp);
  18. }
  19. }
  20.  
  21. template <class T>void operator * (Set <T> second)
  22. {
  23. //Как обратиться к first?
  24. second.Print();
  25. }
  26.  
  27. void Print()
  28. {
  29. set <T>::iterator ik;
  30. for (ik = cs.begin(); ik != cs.end(); ++ik)
  31. cout << *ik << " ";
  32. cout << endl;
  33. }
  34. };
  35.  
  36. int _tmain(int argc, _TCHAR* argv[])
  37. {
  38. setlocale(LC_ALL,"ru");
  39. Set<char>first;
  40. first.Print();
  41.  
  42. first = first + 'd';
  43. first.Print();
  44.  
  45. Set<char>second;
  46. second.Print();
  47.  
  48. first*second;
  49.  
  50. system("pause");
  51. return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement