#include <iostream>

class Int17Matrix3D {
public:

  Int17Matrix3D(int x, int y, int z);

  Int17Matrix3D(const Int17Matrix3D& other);

  ~Int17Matrix3D();

  Int17Matrix3D& operator=(int32_t value);  

  Int17Matrix3D& operator=(const Int17Matrix3D& other);

  static Int17Matrix3D make_array(int x, int y, int z);

  void copy(int32_t* array1, int32_t* array2, int size);

  void SetValueAtCurrentIndex(int32_t value);

  class Proxy2D;
  class Proxy1D;

  Proxy2D operator[](int x);
  const Proxy2D operator[](int x) const;

private:
  const int8_t kNumLenght_ = 17;
  int32_t current_index_;
  int32_t max_index_;
  int32_t width_;
  int32_t height_;
  int32_t depth_;
  int32_t* array_;
  int32_t current_x_ = 0;
  int32_t current_y_ = 0;
  int32_t current_z_ = 0;

  bool TakeBit(const int32_t* value, uint32_t bit_position) const;

  Int17Matrix3D& ClearBit(int32_t* value, int32_t bit_position);

  Int17Matrix3D& SetBit(int32_t* value, int32_t bit_position);

  int GetIndex(int x, int y, int z) const;

  int32_t ToDecimal(const int32_t* array_, int32_t current_index_) const;

  friend Int17Matrix3D operator+(const Int17Matrix3D& lhs, const Int17Matrix3D& rhs);

  friend Int17Matrix3D operator-(const Int17Matrix3D& lhs, const Int17Matrix3D& rhs);

  friend Int17Matrix3D operator*(const Int17Matrix3D& lhs, const int32_t& rhs);

  friend std::ostream& operator<<(std::ostream& stream, const Int17Matrix3D& array);

  friend std::ostream& operator>>(std::ostream& stream, const Int17Matrix3D& array);

  friend bool operator==(const Int17Matrix3D& lhs, int32_t rhs);

  friend bool operator==(int32_t lhs, const Int17Matrix3D& rhs);

  friend bool operator==(const Int17Matrix3D& lhs, const Int17Matrix3D& rhs);

  friend bool operator!=(const Int17Matrix3D& lhs, const Int17Matrix3D& rhs);
};

class Int17Matrix3D::Proxy2D {
  Int17Matrix3D& parentMatrix;
  int x_;

public:
  Proxy2D(Int17Matrix3D& parentMatrix, int x) : parentMatrix(parentMatrix), x_(x) {}

  Proxy1D operator[](int y);
};

class Int17Matrix3D::Proxy1D {
  Int17Matrix3D& parentMatrix;
  int x_, y_;

public:
  Proxy1D(Int17Matrix3D& parentMatrix, int x, int y) : parentMatrix(parentMatrix), x_(x), y_(y) {}

  int& operator[](int z);
};

Proxy2D Int17Matrix3D::operator[](int x) {
  return Proxy2D(*this, x);
}

Int17Matrix3D::Proxy1D Int17Matrix3D::Proxy2D::operator[](int y) {
  return Proxy1D(parentMatrix, x_, y);
}

int& Int17Matrix3D::Proxy1D::operator[](int z) {
  // Calculate the index in the one-dimensional array
  int index = parentMatrix.GetIndex(x_, y_, z);
  // Return a reference to the element
  return parentMatrix.array_[index];
}

[  7%] Building CXX object lib/CMakeFiles/Int17Matrix3D.dir/Int17Matrix3D.cpp.o
In file included from /Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.cpp:2:
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:89:1: error: unknown type name 'Proxy2D'; did you mean 'Int17Matrix3D::Proxy2D'?
Proxy2D Int17Matrix3D::operator[](int x) {
^~~~~~~
Int17Matrix3D::Proxy2D
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:69:22: note: 'Int17Matrix3D::Proxy2D' declared here
class Int17Matrix3D::Proxy2D {
                     ^
1 error generated.
make[2]: *** [lib/CMakeFiles/Int17Matrix3D.dir/Int17Matrix3D.cpp.o] Error 1
make[1]: *** [lib/CMakeFiles/Int17Matrix3D.dir/all] Error 2
make: *** [all] Error 2