Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Field::field_swap(Field& other){
- std::swap(height, other.height);
- std::swap(width, other.width);
- std::swap(field, other.field);
- std::swap(starting_cell, other.starting_cell);
- std::swap(finishing_cell, other.finishing_cell);
- }
- Field::Field(Field&& other){
- this->field_swap(other);
- }
- Field::Field(const Field& other){
- this->width = other.width;
- this->height = other.height;
- this->starting_cell = other.starting_cell;
- this->finishing_cell = other.finishing_cell;
- Cell **tmp;
- tmp = new Cell*[this->height];
- for(int y = 0; y < other.height; y++){
- tmp[y] = new Cell[this->width];
- for(int x = 0; x < other.width; x++)
- tmp[y][x] = other.field[y][x];
- }
- this->field = tmp;
- }
- Field &Field::operator=(const Field& other){
- if(this != &other)
- Field(other).field_swap(*this);
- return *this;
- }
- Field &Field::operator=(Field&& other){
- if(this != &other)
- this->field_swap(other);
- return *this;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement