Advertisement
Ajku

Untitled

Apr 24th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. class Iterator {//ili friend class
  2.     T* dataP;
  3. public:
  4.     Iterator(T* target) : dataP(target) {}
  5.     bool operator != (const Iterator &other) const {
  6.         return dataP != other.dataP;
  7.     }
  8.     bool operator ++(int) {
  9.         dataP++;
  10.     }
  11.     bool operator * () const {
  12.  
  13.     }
  14.     T operator* () const {
  15.         return *dataP;
  16.     }
  17. };
  18. //+proverki
  19.  
  20. class ArrayContainer {
  21.     Iterator begin() const;
  22.     Iterator end() const;
  23. };
  24.  
  25. template <typename T>
  26. typename ArrayContainer<T>::Iterator ArrayContainer<T>::begin() const {
  27.     return Interator(array);
  28. }
  29.  
  30. template <typename T>
  31. typename ArrayContainer<T>::Iterator ArrayContainer<T>::end() const {
  32.  
  33.     return Iterator(!array ? nullptr :array + size);
  34. }
  35.  
  36. for (auto it = test.begin(); it != test.end(); i++) {
  37.     std::cout << *it;
  38. }
  39.  
  40. ArrayContainer<int>& p = test;
  41. auto i = p;
  42. auto&i = p; //!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement